首页 话题 小组 问答 好文 用户 我的社区 域名交易 唠叨

[分享]php常用方法之提取所有图片

发布于 2025-04-11 22:00:25
0
38
function getImgs($content,$order='all'){
	$pattern="/<img.*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
	preg_match_all($pattern,$content,$match);
	if(isset($match[1])&&!empty($match[1])){
		if($order==='all'){
			return $match[1];
		}
		if(is_numeric($order)&&isset($match[1][$order])){
			return $match[1][$order];
		}
	}
	return '';
}
评论
一个月内的热帖推荐
站长交流