How can the in_array function be used to improve the comparison of values in PHP?

When comparing values in PHP, the in_array function can be used to simplify the process and improve readability. This function checks if a value exists in an array, eliminating the need for complex loops or multiple conditional statements. By using in_array, you can easily determine if a specific value is present in an array without having to write extensive code.

// Example of using in_array function to compare values
$fruits = array("apple", "banana", "orange");

if (in_array("apple", $fruits)) {
    echo "Apple is in the array";
} else {
    echo "Apple is not in the array";
}