php正则表达式

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

 

posted on 2016-05-25 15:46  royhoo  阅读(167)  评论(0编辑  收藏  举报

导航