日期:2014-05-17 浏览次数:20478 次
$expression ="/@呲牙/";
$reexpression ="呲牙";
$text=preg_replace($expression,'<img src="www.test.com/static/expression/'.$reexpression.'.gif" /> ',$text);
$expression =array("/@呲牙/","/@鄙视/","/@折磨/");
$reexpression =array("呲牙","鄙视","折磨");
$text=preg_replace($expression,'<img src="www.test.com/static/expression/'.$reexpression.'.gif" /> ',$text);
$text = '别@呲牙了,->@鄙视<-';
$reexpression =array("呲牙","鄙视","折磨");
// 希望你的程序最好以UTF-8编码,u修饰符的作用就是避免编码出现意外的混乱
$find = '#@('. join('
------解决方案--------------------
', $reexpression) .')#u';
$replace = '<img src="www.test.com/static/expression/$1.gif" alt="$1"/>';
$text = preg_replace($find, $replace, $text);