我的阵列出了问题。
$mini_one = array(
"in" => "#pp1",
"ot" => "the-r1",
"fn" => "the_r1()",
"js" => "$('the-r1').val($('#pp1').val());",
"ep" => "not tested"
);
$mini_two = array(
"in" => "#pp1",
"ot" => "the-r1",
"fn" => "the_r1()",
"js" => "$('the-r1').val($('#pp1').val());",
"ep" => "not tested"
);
//these are different but i just c/p it to show more than one array
//inside of $big_array
$big_array = array($mini_one,$mini_two);
但是当我用is_array()测试big_array时它返回false,它在我的foreach循环中也不起作用。
我想知道为什么它不是一个数组?,我怎么能把它变成一个正确的数组?,而且,就像现在一样,它被认为是什么类型的构造?
答案 0 :(得分:0)
代码正确
print_r($big_array);
if(is_array($big_array)) echo 'is array'; else echo 'not array';
将输出“is array”
答案 1 :(得分:0)
您需要为我们粘贴确切的数组,以了解最新情况。我尝试使用上面的代码片段,它的工作原理。 你的$ big_array将如下所示
Array
(
[0] => Array
(
[in] => #pp1
[ot] => the-r1
[fn] => the_r1()
[js] => $('the-r1').val($('#pp1').val());
[ep] => not tested
)
[1] => Array
(
[in] => #pp1
[ot] => the-r1
[fn] => the_r1()
[js] => $('the-r1').val($('#pp1').val());
[ep] => not tested
)
)
so its multidimensional to loop through it with foreach you need to do the following.
foreach($big_array as $k=>$v) {
foreach($v as $v1) {
echo $v1."<br>";
}
}