How can the in_array function be used to compare values in multidimensional arrays in PHP?

When comparing values in multidimensional arrays in PHP, the in_array function can be used by setting the third parameter to true. This third parameter, strict, ensures that both the value and the type of the elements are checked for equality. By using this parameter, the in_array function can accurately compare values in multidimensional arrays.

$multiArray = array(
    array("apple", "banana"),
    array("orange", "grape")
);

$searchValue = "apple";

foreach ($multiArray as $subArray) {
    if (in_array($searchValue, $subArray, true)) {
        echo "Value found in multidimensional array!";
        break;
    }
}