What alternative function to strpos() is suggested for searching multiple words in an array in PHP?

When searching for multiple words in an array in PHP, using the preg_grep() function is a suggested alternative to strpos(). This function allows for searching using regular expressions, making it easier to search for multiple words at once.

<?php
// Array to search
$array = ["apple", "banana", "orange", "grape"];

// Words to search for
$words = ["apple", "orange"];

// Search for words in the array using preg_grep
$results = preg_grep('/' . implode('|', $words) . '/', $array);

// Output the results
print_r($results);
?>