来自stdClass对象的引用字段,其中包含可绘制信息的数组

时间:2018-10-18 17:22:38

标签: php drupal-7

我想从以下包含嵌套数组和stdClass对象的大规模混合数据数组中返回Birthday字段的值。我尝试了以下代码,但没有用,对于任何帮助,我将非常感谢。

$data->_field_data['nid']['entity']->field_player_birthday['und'][0]['value'];

PHP:

stdClass::__set_state(array(
    'node_field_data_field_game_players_nid' => '2931', 
    'node_title' => '1539634465', 
    'nid' => '8114', 
    'node_language' => 'tr',
    'field_data_field_player_birthday_node_entity_type' => 'node',
    '_field_data' => array ( 
        'node_field_data_field_game_players_nid' => array ( 
                'entity_type' => 'node', 
                'entity' => stdClass::__set_state(
                    array( 'vid' => '2931', 
                            'uid' => '1', 
                            'title' => 'Fernando Muslera', 
                            'log' => '', 
                            'status' => '1', 
                            'comment' => '1',
                            'promote' => '0', 
                            'sticky' => '0', 
                            'ds_switch' => '', 
                            'nid' => '2931',
                            'type' => 'player', 
                            'language' => 'und', 
                            'created' => '1520727843',
                            'changed' => '1539137801', 
                            'tnid' => '0', 
                            'translate' => '0',
                            'revision_timestamp' => '1539137801',      
                            'revision_uid' => '1', 
                            'body' =>
 array ( ), 'field_player_address' => array ( 'und' => array ( 0 =>
 array ( 'country' => 'AR', 'administrative_area' => 'B',
 'sub_administrative_area' => NULL, 'locality' => 'Buenos Aires',
 'dependent_locality' => '', 'postal_code' => '', 'thoroughfare' => '',
 'premise' => '', 'sub_premise' => NULL, 'organisation_name' => NULL,
 'name_line' => NULL, 'first_name' => NULL, 'last_name' => NULL, 'data'
 => NULL, ), ), ), 'field_geofield' => array ( 'und' => array ( 0 => array ( 'geom' => 'POINT (-58.3815591 -34.6036844)', 'geo_type' =>
 'point', 'lat' => '-34.603684400000', 'lon' => '-58.381559100000',
 'left' => '-58.381559100000', 'top' => '-34.603684400000', 'right' =>
 '-58.381559100000', 'bottom' => '-34.603684400000', 'geohash' =>
 '69y7pkxfgjdq4', ), ), ), 'field_player_search_news' => array ( ),
 'field_player_map' => array ( ), 'field_player_birthday' => array (
 'und' => array ( 0 => array ( 'value' => '1986-06-16 00:00:00',
 'timezone' => 'America/New_York', 'timezone_db' => 'America/New_York',
 'date_type' => 'datetime', ), ), ), 'field_player_team' => array (
 'und' => array ( 0 => array ( 'tid' => '328', ), ), ), 'field_image'
 => array ( ), 'field_game_rating' => array ( 'und' => array ( 0 => array ( 'rating' => '90', 'target' => NULL, ), ), ), 'rdf_mapping' =>
 array ( 'rdftype' => array ( 0 => 'sioc:Item', 1 => 'foaf:Document',
 ), 'title' => array ( 'predicates' => array ( 0 => 'dc:title', ), ),
 'created' => array ( 'predicates' => array ( 0 => 'dc:date', 1 =>
 'dc:created', ), 'datatype' => 'xsd:dateTime', 'callback' =>
 'date_iso8601', ), 'changed' => array ( 'predicates' => array ( 0 =>
 'dc:modified', ), 'datatype' => 'xsd:dateTime', 'callback' =>
 'date_iso8601', ), 'body' => array ( 'predicates' => array ( 0 =>
 'content:encoded', ), ), 'uid' => array ( 'predicates' => array ( 0 =>
 'sioc:has_creator', ), 'type' => 'rel', ), 'name' => array (
 'predicates' => array ( 0 => 'foaf:name', ), ), 'comment_count' =>
 array ( 'predicates' => array ( 0 => 'sioc:num_replies', ), 'datatype'
 => 'xsd:integer', ), 'last_activity' => array ( 'predicates' => array ( 0 => 'sioc:last_activity_date', ), 'datatype' => 'xsd:dateTime',
 'callback' => 'date_iso8601', ), ), 'path' => array ( 'pathauto' =>
 '1', ), 'cid' => '0', 'last_comment_timestamp' => '1520727843',
 'last_comment_name' => NULL, 'last_comment_uid' => '1',
 'comment_count' => '0', 'name' => 'efet', 'picture' => '0', 'data' =>
 'a:7:{s:7:"contact";i:1;s:5:"block";a:1:{s:6:"system";a:1:{s:4:"main";i:1;}}s:16:"ckeditor_default";s:1:"t";s:20:"ckeditor_show_toggle";s:1:"t";s:14:"ckeditor_width";s:4:"100%";s:13:"ckeditor_lang";s:2:"en";s:18:"ckeditor_auto_lang";s:1:"t";}',
 )), ), ), 'field_field_player_birthday' => array ( 0 => array (
 'rendered' => array ( '#markup' => '1986', '#access' => true, ), 'raw'
 => array ( 'value' => '1986-06-16 00:00:00', 'timezone' => America/New_York', 'timezone_db' => 'America/New_York', 'date_type'
> => 'datetime', ), ), ), ))

1 个答案:

答案 0 :(得分:0)

您就近了(因为我不得不稍微更改一下对象以进行测试,所以我希望这能奏效)...

echo $data->_field_data['node_field_data_field_game_players_nid']['entity']
           ->field_player_birthday['und'][0]['value'];

基本上是nid,而不是node_field_data_field_game_players_nid