PHP加速取代?

时间:2014-12-29 19:44:44

标签: php

如何提高以下代码的性能:

$text = str_replace("A", "B", $text);
$text = str_replace("f", "F", $text);
$text = str_replace("c", "S", $text);
$text = str_replace("4", "G", $text);
//more str_replace here

1 个答案:

答案 0 :(得分:2)

将其作为一个函数调用:

$text = str_replace(["A","f","c","4"], ["B","F","S","G"], $text);