这是var_dump($options)
我怎样才能通过这个数组循环 - PHP
array (size=4)
0 => string '2' (length=1)
'parent_2_children' =>
array (size=3)
0 => string '22' (length=2)
1 => string '24' (length=2)
2 => string '23' (length=2)
1 => string '3' (length=1)
'parent_3_children' =>
array (size=3)
0 => string '26' (length=2)
1 => string '25' (length=2)
2 => string '27' (length=2)
我曾尝试到现在
if(!is_null($options))
{
foreach($options as $option)
{
if(!array_key_exists('parent_'.$option.'_children',$options))
{
//if position null output an error
}
}
}
的要求
Array
(
[0] => 2
[parent_2_children] => Array
(
[0] => 22
[1] => 24
[2] => 23
)
[1] => 3
[parent_3_children] => Array
(
[0] => 26
[1] => 25
[2] => 27
)
)
当你循环阅读时你想做什么? –
如果position null输出错误 – Techie
您现有的代码应该没问题。 –