The following code will probably be understood better by advanced user, this code will only search array elements.
meaning if you have $array[books][php][0] and you are searching for 'php' it will not find the [php] array, i am sure that with minor
modifications you could make it find either the element or an array element.
Hopefully this code will help someone else, i just spent 30 minutes getting this to work ;)
<?php
// the function that will recursivly search an array.
function searchArrayRecursive($needle, $haystack){
// loop through the haystack that has been passed in
foreach ($haystack as $key => $arr) {
// check to make sure that the element is an array
if(is_array($arr)) {
/* this is the tricky line, this will take the value
or $arr and call the function again each time
the function is called, $ret is set with the
return value of the function call, this builds
the string that get's returned.
*/
$ret=searchArrayRecursive($needle, $arr);
/* check to make sure that the function call did
not return -1 and return the value of the $key and
the $ret
*/
if($ret!=-1) return $key.','.$ret;
} else {
/* check the array element and see if it matches the
search term. if it does, return the $key of the
element.
*/
if($arr == $needle) return (string)$key;