function find_words($content) { $result = mysql_query("SELECT word from dictionary")or die(mysql_error()); $words=array(); while($row=mysql_fetch_array($result)) $words[]= "/\\b($row[0])\\b/"; $newData = preg_replace($words, '$1', $content); echo $newData; }