织梦正则批量给文章内容里的图片alt递增数字
2019-08-31
摘要:内容模板中 {dede:field.body/} 改成 {dede:field.body runphp=yes}$string = @me;$myi = 1;@me = preg_replace_callback('/(img.*?alt=[\"|\'])(.*?)([\"|\'].*?)/', function($match) use ($myi){return $match[1].$match[2].($myi++).$match[3];},$
内容模板中{dede:field.body/}改成
{dede:field.body runphp=yes}
$string = @me;
$myi = 1;
@me = preg_replace_callback('/(<img.*?alt=[\"|\'])(.*?)([\"|\'].*?>)/', function($match) use (&$myi){return $match[1].$match[2].($myi++).$match[3];},$string);
{/dede:field.body}