What is the function "in_array()" used for in PHP?

The "in_array()" function in PHP is used to check if a specified value exists in an array. This function returns true if the value is found in the array, and false otherwise. It is commonly used to determine if a certain element is present in an array before performing further actions based on its presence.

// Example usage of in_array() function
$fruits = array("apple", "banana", "orange", "kiwi");
$search = "orange";

if (in_array($search, $fruits)) {
    echo $search . " is found in the array.";
} else {
    echo $search . " is not found in the array.";
}