What is the function of the array_search() function in PHP?
The array_search() function in PHP is used to search an array for a specific value and return the corresponding key if the value is found. This function can be useful when you need to find the key of a specific value within an array without knowing its position. Here is an example of how to use the array_search() function in PHP:
$fruits = array("apple", "banana", "orange", "grape");
$search_value = "orange";
$key = array_search($search_value, $fruits);
if($key !== false) {
echo "The key of '$search_value' is: $key";
} else {
echo "Value not found in the array";
}