正则替换问题 多关键字加亮
PHP code
$k=array("i","n");$row="iphone";$row = preg_replace("/($k[0])/i", "\\1", $row);$row = preg_replace("/($k[1])/i", "\\1", $row);echo $row;//输出 nt color=red>int>phone//怎么样才能让关键字也就是$k里面的字母变为红色的?不重复替换?
登录后复制


------解决方案--------------------
PHP code
$k=array("i","n");$p= join('',$k);$row="iphone";echo  preg_replace("/[".$p."]/i", "\\0", $row);

09-13 02:09