我必须遵循以下不同的多维数组:
Array
(
[1] => Array
(
[0] => 1
[1] => 2
)
[2] => Array
(
[0] => 1
)
)
Array
(
[1] => Array
(
[0] => 1
[1] => 2
)
[2] => Array
(
[0] => 1
[1] => 2
)
[3] => Array
(
[0] => 1
)
)
我想检查较大的数组中是否存在小的多维数组。有任何建议请。 我正在使用
$diff = Hash::diff(samllarray, $bigger array);
cakephp的及其结果是
Array
(
[2] => Array
(
[0] => 1
)
[3] => Array
(
[0] => 1
)
)
但结果我只想要第3个键,但它也给了我第2个键,见上面
答案 0 :(得分:0)
您可以使用is_array()
查看变量是否为数组。
$arrs = array(
0 => "big array",
1 => "big array",
3 => array(
0 => "nested array",
1 => "nested array"
)
);
foreach ($arrs as $key=>$value) {
if (is_array($value)) {
echo "we've got an array at index {$key}";
}
}