What is the potential issue with using in_array function in PHP with multidimensional arrays?

The issue with using in_array function in PHP with multidimensional arrays is that it only checks for the presence of a value in the first level of the array. To properly check for a value in multidimensional arrays, you can use a recursive function that traverses through all levels of the array.

function recursive_in_array($needle, $haystack) {
    foreach ($haystack as $item) {
        if (is_array($item)) {
            if (recursive_in_array($needle, $item)) {
                return true;
            }
        } else {
            if ($item === $needle) {
                return true;
            }
        }
    }
    return false;
}

// Example usage
$haystack = [[1, 2], [3, 4], [5, [6, 7]]];
$needle = 7;

if (recursive_in_array($needle, $haystack)) {
    echo "Value found in array.";
} else {
    echo "Value not found in array.";
}