错误获取php数组项目 - >未定义的索引:节点

时间:2018-01-29 21:48:58

标签: php arrays

我在访问“节点”项目时遇到问题

这是来自我的数组

的print_r的一块

在这篇文章的最后一行  print_r($ item ['nodes']); //< - 这不起作用

它是怎么来的,我一定是做错了什么但是无法弄清楚

提前thx 伯特

Array
(
[id] => 1
[name] => Drinken
[view-url] => Array
(
[0] => pu/default/view
[id] => 1
)
[update-url] => Array
(
[0] => pu/default/update
[id] => 1
)
[create-url] => Array
(
[0] => pu/default/create
[id] => 1
)
[delete-url] => Array
(
[0] => pu/default/delete
[id] => 1
)
[nodes] => Array
(
[0] => Array
(
[id] => 1^1
[name] => Cola
[view-url] => Array
(
[0] => group/default/view
[id] => 1
)

[update-url] => Array
(
[0] => group/default/update
[id] => 1
)
[create-url] => Array
(
[0] => group/default/create
[id] => 1
)
[delete-url] => Array
(
[0] => group/default/delete
[id] => 1
)
)

foreach ($items as $item) {
echo "<div id='trvid_" . $item['id'] . "' class='trvwcatname'>" . $item['name'] . "</div>";
echo '<pre>';
print_r($item);
echo '</pre>';
echo '<hr>';
print_r($item['id']);// <-- this works
echo '<hr>';
print_r($item['view-url']);// <-- this works
echo '<hr>';
print_r($item['nodes']);// <-- this doesnt works
}

0 个答案:

没有答案