正则匹配 img标签的src 然后替换

function get_img_thumb_url($content="",$suffix="http://www.sanfo.com")
{
$pregRule = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/";
$content = preg_replace($pregRule, '<img src="'.$suffix.'${1}" style="max-width:100%">', $content);
return $content;
}

猜你喜欢

转载自blog.csdn.net/yao978318542/article/details/78364052
今日推荐