Suppose there are 3 keywords,
I don't want to do this kind of replace 3 times:
a => <b>a</b>
str_replace ( 'a', '<b>a</b>', $str)
Is it possible to do it by one run?
Suppose there are 3 keywords,
I don't want to do this kind of replace 3 times:
a => <b>a</b>
str_replace ( 'a', '<b>a</b>', $str)
Is it possible to do it by one run?
收起
You can use the strtr (or mb_strtr) function in PHP
$trans = array("hello" => "hi", "said" => "screamed");
echo strtr("hi all, I said hello", $trans); // prints out "hi all, I screamed hi"
报告相同问题?