As mentioned in the title im trying to replace more than one string and im worndering if its possible with str_replace(); Or is there a easier way?
Example:
str_replace('hello','#$@&%*!',$text);
I'm replacing "hello" with "#$@&% !" but i also want "world" to get replaced with "#$@&% !" .
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] ) Parameter "search": The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
Try this
$text = 'hello this is world';
echo str_replace(array('hello','world'),'#$@&%*!',$text);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.