php 提取文章内容中的图片

/** getmessagepic()提取文章内容中的图片
* @param string $content
* @return string
*/
function getcontentpic($content) {
$pic = '';
$content = stripslashes($content);
$content = preg_replace("/\<img src=\".*?image\/face\/(.+?).gif\".*?\>\s*/is", '', $content); //移除表情符
preg_match("/src\=[\"\']*([^\>\s]{25,105})\.(jpg|gif|png)/i", $content, $mathes);
if(!empty($mathes[1]) || !empty($mathes[2])) {
$pic = "{$mathes[1]}.{$mathes[2]}";
}
return addslashes($pic);
}

猜你喜欢

转载自www.cnblogs.com/jierong12/p/9152197.html