How can the PHP in_array function be used to search for values in an array?

The PHP in_array function can be used to search for specific values within an array. It returns true if the value is found in the array, and false otherwise. To use the in_array function, simply provide the value you want to search for and the array to search within as arguments.

// Example of using in_array function to search for a value in an array
$fruits = array("apple", "banana", "orange", "kiwi");

if (in_array("banana", $fruits)) {
    echo "Found banana in the array!";
} else {
    echo "Banana not found in the array.";
}