After reading the comments, the answer is simple. You just asking if there is any built in PHP function which does this task.
Answer: No there is no built-in function for that, you have write your own. It should lead to an recursive algorithm. (or even iterative, as recursion can always be replaced by iteration).
Here comes a function which will do the job. Note that I've replaced recursion by iteration, in order to tweak the algorithm:
$a = array(
array(
'cat','d'=>'fox',
),
'x' => array(
'y'=> array('fox'),
),
);
function pathto($value, $array) {
// init stack
$stack = array(array($array, 'array'));
do {
// get first value from stack
list ($current_value, $current_path) = array_shift($stack);
// if current is a scalar value then compare to the input
if($current_value === $value) {
echo $current_path . PHP_EOL;
continue;
}
// push array childs to stack
if(is_array($current_value)) {
foreach($current_value as $k => $v) {
$k = is_string($k) ? "'$k'" : $k;
// push child and path to file
array_push($stack, array (
$v, $current_path . '[' . $k . ']'
));
}
}
} while (!empty($stack));
}
pathto('fox', $a);
Output:
$test[0]['d']
$test['x']['y'][0]