经测试代码如下:
<?PHP
/**
* 获取网页所有图片地址,并存入数组
*
* @param
* @arrange (512.笔记) jb51.cc
**/
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i',$data,$media);
unset($data);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);
foreach($data as $url)
{
$info = pathinfo($url);
if (isset($info['extension']))
{
if (($info['extension'] == 'jpg') ||
($info['extension'] == 'jpeg') ||
($info['extension'] == 'gif') ||
($info['extension'] == 'png'))
array_push($images,$url);
}
}
/*** 来自:编程之家 jb51.cc(jb51.cc) ***/
?>
原文链接:https://www.f2er.com/php/528766.html