【发布时间】:2017-12-04 09:31:46
【问题描述】:
我在访问数组中的索引 1 时遇到问题。
如何访问index 1?
尝试这样访问。
$selection = $menu_selection->{1}->vl
但它显示未定义的偏移错误。谁能帮帮我。
Array
(
[1] => stdClass Object
(
[vl] => Array
(
[0] => 1
[1] => 2
)
[op] => Array
(
[0] => O
[1] => O
)
)
[189] => Array
(
[vl] => Array
(
[0] => 1
)
)
)
【问题讨论】:
-
您可以使用
[index]表示法访问数组,那么您是否尝试过$selection = $menu_selection[1]->vl? -
$menu_selection[1]->vl[0] -
我试过....错误是未定义的偏移量 1。
-
我认为索引不是数组,它是数组中的一个对象...那我怎么访问它呢?
标签: php arrays object multidimensional-array