in_array() and multidimensional array

Posted by lauthiamkok on Stack Overflow See other posts from Stack Overflow or by lauthiamkok
Published on 2010-11-08T21:39:30Z Indexed on 2012/09/17 9:38 UTC
Read the original article Hit count: 312

I use in_array() to check whether a value exists in an array like below,

$a = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $a)) 
{
    echo "Got Irix";
}

//print_r($a);

but what about an multidimensional array (below) - how can I check that value whether it exists in the multi-array?

$b = array(array("Mac", "NT"), array("Irix", "Linux"));

print_r($b);

or I shouldn't be using in_array() when comes to the multidimensional array?

© Stack Overflow or respective owner

Related posts about php

Related posts about multidimensional-array