What are some common pitfalls when using preg_match for searching multiple words in PHP?

When using preg_match for searching multiple words in PHP, a common pitfall is not properly constructing the regular expression to match all the words. To solve this, you can use the "|" (pipe) character to separate the words within the regular expression pattern.

$words = array('apple', 'banana', 'orange');
$search_string = 'I like apples and bananas';

$pattern = '/'.implode('|', $words).'/i';

if (preg_match($pattern, $search_string)) {
    echo 'Found a match!';
} else {
    echo 'No match found.';
}