时间:2021-07-01 10:21:17 帮助过:11人阅读
显示远程图片:
?
第一种: 精确型
?
' : "false";
?
第二种:从文章中提取图片,并保存至本地
function getImg($str){
$str = stripslashes($str);
$pattern = "/
]*src\=\"(([^>]*)(jpg|gif|png|bmp|jpeg))\"/i"; //获取所有图片标签的全部信息
preg_match_all($pattern, $str, $matches);
return $matches[1]; //$matches[1]中就是所想匹配的结果,结果为数组
}
$str = <<
This article was originally published on Benzinga, and is republished here with permission.
EOT;
foreach( getImg($str) as $url)
{
get_photo($url);
}
?