Easy enough to do on your own
$arr = array(/* your array structure here ofc */);
$searchId = 15;
for ($catInd = 0, $notFound = true; $notFound && $catInd < count($arr); ++$catInd) {
for ($prodInd = 0; $notFound && $prodInd < count($arr[$catInd]; ++$prodInd)
if ($arr[$catInd][$prodInd]['productId'] == $searchId) {
$matchingCategory = $catInd;
$matchInsideCategory = $prodInd;
$notFound = false;
}
}
You could easily use array_walk_recursive as well, but you'd need a global variable to hold the matching array element, so it doesn't feel like a nice solution. Besides, you can break out of recursion. Even if your match was in the first element, it'd run through the lot of them.
It's possible there is an existing solution among the one thousand and one array functions. If you want to check this for yourself, just search for array on php.net, find array functions and start going through them 🙂