<?php function getImgs($content,$order='ALL'){ $pattern="/<img.*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/"; 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 ''; }
PHP获取html内容中的所有图片或第一张图片地址
发表于
发表回复