php 得到文章中第一个图片的链接
得到文章中第一个图片的链接 [代码片段(13行)]
function pickupImage($html) {
preg_match_all('/<img.+?>/U', $html, $matches, PREG_PATTERN_ORDER);
if(count($matches[0]) > 0) {
foreach ($matches[0] as $match)
{
preg_match('/src="(.+)"/U', $match, $src);
return $src[1];
}
}
else
return '';
}
//该片段来自于http://outofmemory.cn
- 上一篇:php 带附件的邮件发送
- 下一篇:php 删除指定的html标签
精彩图集
精彩文章






