function get_img_load_url($content="",$suffix="/images/load.gif")
{
$pregRule = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/";
$content = preg_replace($pregRule, '<img src="'.$suffix.'" data-src="${1}">', $content);
return $content;
}
$array = [
0 => '<p><img src="1.jpg" /></p>',
1 => '<p><img src="2.jpg" /></p>',
2 => '<p><img src="3.jpg" /></p>',
];
foreach ($array as $k => $v) {
$newImg = get_img_load_url($v);
print_r($newImg);
}
本文为会飞的鱼原创文章,转载无需和我联系,但请注明来自会飞的鱼博客https://php.daiying.net.cn
最新评论