Well, I already writed about str_replace php function but this tip is very usefull. To recap, the function it’s used to replace a string by using three paramaters : $stringToSearch, $stringToReplace, $intoString. I showed you how to use it in single operations but we can use it for multiple replaces in one place, by using arrays :
<?php $searchArray = array("word1", "sound2", "etc3"); $replaceArray = array("word one", "sound two", "etc three"); $intoString = "Here is word1, as well sound2 and etc3"; //now let's replace print str_replace($searchArray, $replaceArray, $intoString); //it should print "Here is word one, as well sound two and etc three" ?>
I have to say this multiple replace “trick” is a very nice one!
See ya soon!