I\'d like to change with
. and
with
I\'m having problem with t
I found a very easy solution to replace multiple words in a string :
Hello world!
";
$pattern=array();
$pattern[0]="//";
$pattern[1]="/<\/pre>/";
$replacement=array();
$replacement[0]="";
$replacement[1]="
";
echo preg_replace($pattern,$replacement,$str);?>
output :
Hello world!
With this script you can replace as many words in a string as you want :
just place the word (that you want to replace) in the pattern array , eg :
$pattern[0]="/replaceme/";
and place the characters (that will be used in place of the replaced characters) in the replacement array, eg :
$replacement[0]="new_word";
Happy coding!