How can the in_array() function in PHP be utilized to check for the existence of a specific value in an array?

To check for the existence of a specific value in an array in PHP, you can use the in_array() function. This function takes two parameters: the value you want to check for and the array you want to search. It returns true if the value is found in the array, and false otherwise.

// Example array
$fruits = array("apple", "banana", "orange");

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