What is the best way to search for a specific word in an array in PHP?

When searching for a specific word in an array in PHP, you can use the `array_search()` function. This function searches for a given value in an array and returns the corresponding key if found. If the word is not found, `array_search()` returns `false`.

$words = array("apple", "banana", "cherry", "date", "elderberry");
$search_word = "cherry";

$key = array_search($search_word, $words);

if ($key !== false) {
    echo "The word '$search_word' was found at index $key.";
} else {
    echo "The word '$search_word' was not found in the array.";
}