How can more efficient code be written to check for values in multiple arrays using in_array in PHP?

When checking for values in multiple arrays using in_array in PHP, a more efficient approach would be to combine all the arrays into one and then perform the check. This reduces the number of in_array calls and simplifies the code.

// Combine all arrays into one
$combinedArray = array_merge($array1, $array2, $array3);

// Check for value in the combined array
if (in_array($value, $combinedArray)) {
    echo "Value found in the arrays.";
} else {
    echo "Value not found in the arrays.";
}