来自 stdClass 对象的引用字段,其中包含可绘制信息的数组
Referencing field from stdClass Object which contains an array of drawable information
我想 return 从以下包含嵌套数组和 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', ), ), ), ))
你很接近(因为我不得不稍微改变对象来测试,我希望这有效)...
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
。
我想 return 从以下包含嵌套数组和 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', ), ), ), ))
你很接近(因为我不得不稍微改变对象来测试,我希望这有效)...
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
。