in_array()在多维数组上不起作用。您可以编写一个递归函数来为您做到这一点:
function in_array_r($needle, $haystack, $strict = false) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { return true; } } return false;}用法:
$b = array(array("Mac", "NT"), array("Irix", "Linux"));echo in_array_r("Irix", $b) ? 'found' : 'not found';


