What is the function to search for a specific value in an array and return its key in PHP?

To search for a specific value in an array and return its key in PHP, you can use the array_search() function. This function searches an array for a given value and returns the corresponding key if the value is found. If the value is not found, it returns false. Here is an example of how to use array_search() to search for a specific value in an array and return its key:

$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";
}