I needed a recursive in_array function the other day and disliked all the samples I found on php.net. I wrote this one using the StandardPHPLibrary. It will recursively search through a multidimensional array and return true if the $needle is found in the $haystack.

 
function in_array_recursive($needle, $haystack) {
 
    $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($haystack));
 
    foreach($it AS $element) {
        if($element == $needle) {
            return true;
        }
    }
 
    return false;
}