problem with preg_replace
| From: | Gregor Jaksa | Date: | Tue, 13 Jan 2004 14:08:34 +0000 |
| Subject: | problem with preg_replace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174443@lists.php.net to get a copy of this message | ||
hello, i need to replace some words in file with [tag]word[/tag] and other
words with [sample]word[/sample].
i have a list of words which i need to replace with [sample] tags declared
like
$words = 'word1|word2|word3|word4';
replacing those words is easy i just use preg_replace('/\b( ' . $words .
')\b/i', '[sample]$1[/sample]', $file);
but how to replace all other words that are not in $words array with [tag]
tag ?
thx in advance!