print_r($rows)
返回此:如何获取嵌套数组/对象中的这条信息?
Array
(
[S1 | Excellence in P-O-P Execution: Ripping Down the Roadblocks to Breakthrough In-Store Marketing] => Array
(
[group] => S1 | Excellence in P-O-P Execution: Ripping Down the Roadblocks to Breakthrough In-Store Marketing
[rows] => Array
(
[0] => stdClass Object
(
[nid] => 207
[node_title] => Excellence in P-O-P Execution: Ripping Down the Roadblocks to Breakthrough In-Store Marketing
[taxonomy_term_data_field_data_field_track_term_tid] => 19
[node_field_data_field_speaker_title] => Jon Kramer
[node_field_data_field_speaker_nid] => 205
[field_data_field_date_time_field_date_time_value] => 2012-10-16 18:00:00
[field_data_field_session_number_field_session_number_value] => S1
[field_data_field_date_time_node_entity_type] => node
[field_data_field_session_number_node_entity_type] => node
[field_data_field_track_icon_taxonomy_term_entity_type] => taxonomy_term
[field_data_field_job_title_node_entity_type] => node
[field_data_field_company_node_entity_type] => node
[field_data_field_hide_track_node_entity_type] => node
(我知道我丢失了所有的封闭括号;返回实际上是几千线长,我只是懒得去通过,并找到所有他们。)
我怎么会去为所谓的NID数据片的故事吗?我原以为它会是
$rows[0]['rows'][0]->nid
但我得到一个未定义的偏移错误。我完全无法使用全部内容(S1 | Excellence等)访问数组的第一级 - 这是动态生成的。我曾经想过,因为它是我可以用零点偏移得到的数组的第一个元素,但显然不是。
更新
我试着用current()
按照下面的答案几件事情;它让我更靠近一个级别,但仍然无法访问nid元素。
$row = current($rows);
$nid_tmp = $row['rows'];
print '<pre>'; var_dump($nid_tmp); print '</pre>';
返回
Array
(
[0] => stdClass Object
(
[nid] => 207
精细;这就是我期待的。但是,当我尝试print $nid_tmp[0]->nid
,我得到的通知“:试图让非对象的财产”的错误。
所以后来我怎么的元素?我假设我不能做像'current($ rows)[0] - > nid';是否必须将'current($ rows)'的结果设置为另一个变量,然后从那里开始? – EmmyS
我完全陷在这里。我正在更新OP,以显示迄今为止我尝试过的内容以及给出的结果。 – EmmyS
我已添加到我的答案。我想你在第一条评论中错过了一个级别。也许。谁做这个阵列不是你的朋友。 :) –