Modify code, which searches for a certain word in a tex and ads a span class to it, to work with arrays
<p>Please take a look at this code (thanks to user budwiser), it matches a certain word in a text and ads a span class to it:</p>

<pre><code>function highlightWord($word, $text){
    return str_replace($word, '&lt;span class="highlighted"&gt;' . $word . '&lt;/span&gt;', $text);
}

$text = highlightWord('fitness', $text);
</code></pre>

<p>Any ideas how to make this code work for arrays?</p>

<p>I'd need something like this:</p>

<pre><code>$words = array("fitness", "aerobic", "fashion");

$text = highlightWord($words, $text);
</code></pre>

<p>Any ideas?</p>

<p>Thank you!</p>

<p><strong>UPDATE</strong></p>

<pre><code>$profile_rule = 'profile LIKE (\'fitness\') AND profile LIKE (\'aerobic\')';
preg_match_all('/\'(.*?)\'/',$profile_rule,$match);
</code></pre>

<p>Any idea why $match array does not work?
I want to extract the words fitness and aerobic from the $profile_rule and use the $match array for the function above.</p>

<p>Ty!</p>
