str_replace替换字符串小技巧

$str = '人非圣贤孰能无过';
$str = str_replace(array('人', '非', '圣贤', '无过'), array('我们', '都不是', '圣人', '没有过错'), $str);
echo $str;

结果:

我们都不是圣人孰能没有过错

你可能感兴趣的:(PHP)