How to check if a specific value exists at a specific key in any subarray of a multidimensional array?

Nothing will be faster than a simple loop. You can mix-and-match some array functions to do it, but they’ll just be implemented as a loop too.

function whatever($array, $key, $val) {
    foreach ($array as $item)
        if (isset($item[$key]) && $item[$key] == $val)
            return true;
    return false;

Leave a Comment