Log in

View Full Version : mutiple str_replace?



lankinator
07-21-2007, 10:01 AM
I have tried to enter the str_replace string, but with the last part, in bold, str_replace("example","dd",$text);
it shows the value of $text, as it should i think.
now if i do,
str_replace("example","dd",$text);
str_replace("dynamic","dd",$text);

it will print the content of $text 2 times, because (i think) of the $text part....

how do you stop it from showing the content of $text more than once?

P.S - Sorry if i have confused you :confused:

djr33
07-21-2007, 11:21 AM
$text = str_replace($find1,$replace1,$text);
$text = str_replace($find2,$replace2,$text);
echo $text;


You need to set something equal to the value of str_replace, not just run it.
str_replace() by itself is no more productive than running the line "$text;". That won't generate output or change the stringe.

Then simply use echo when you would like for the new version of $text, and that's it.