日期:2014-05-17 浏览次数:20577 次
$html = "<div>abc,abc,abc,<span>abc</span>,......</div>";
echo preg_replace('/abc/e','++$i',$html);
$str = '<div>abc,abc,abc</div><span>abc</span>';
$i=1;
$newstr = preg_replace_callback('
------解决方案--------------------
abc
------解决方案--------------------
', function($match) use(&$i){return $i++;}, $str);
echo $newstr;