例如:
$str = 'This is stackoverflow and stackexchange.';
如果我们定义了变量$stackoverflow = 'awesome';``$stackexchange = 'great';
则$str
变为:
'This is awesome and great.'
str_ireplace(array('stackoverflow','stackexchange'),array('awesome','great'),$your_string);
希望这是你想要的
像这样?你可以把所有的名字放在数组中。
<?php
$old_values = array('stackoverflow','stackexchange');
$new_values = array('awesome','great');
$str = 'This is stackoverflow and stackexchange.';
$str = str_replace($old_values,$new_values,$str);
?>