I'd like to be able to find the entire key for a given value in a multi-dimensional array. So assuming an array named $structure with the following output: Array ( [0] => Array ( [path] => ../content/about [name] => about [kind] => directory [content] => ) [1] => Array ( [path] => ../content/contact [name] => contact [kind] => directory [content] => ) [2] => Array ( [path] => ../content/resources [name] => resources [kind] => directory [content] => ) } For example, I'd like to be able to feed the function the array name ($structure) and a value of "resources" and have it return "[2][name]". Here is what I have so far and I'm pretty stumped: [code]function getNavItemIndex($navItem, $haystack) { $arrStr = ""; foreach ($haystack as $k => $v) { if(is_array($v)) { getNavItemIndex($navItem, $v); } else { if ($v == $navItem) { $thisIndex = $k; break; } } } return $thisIndex; }[/code] I call the function on itself recursively because I'll never know how deep the array goes. So I just keep going through each one until the value is a string and not an array. I've got 2 problems: 1. when I get a value for $thisIndex, it only reflects the key of the last array looped through. In the case of the example above it would be "name" rather than "[2][name]". 2. Even if #1 were not an issue, the function always returns an empty string, even through $thisIndex can be printed out within the function... scope issue?? Any help would be appreciated!