1、字符串替换多个关键字
1 $pattern = array('/a/', '/a/', '/a/'); 2 $replacement = array('x', 'y', 'z'); 3 $subject = 'abcadeafg'; 4 $res = preg_replace($pattern, $replacement, $subject , 1); 5 echo $res; // xbcydezfg