php 封存远程图片到本地
程序员文章站
2022-05-21 15:37:13
...
php 保存远程图片到本地
?header('Content-Type:image/jpg'); echo file_get_contents("http://www.baidu.com/img/baidu_logo.gif"); ?>
显示远程图片:
?header('Content-Type:image/jpg'); echo file_get_contents("http://www.baidu.com/img/baidu_logo.gif"); ?>
?
第一种: 精确型
?
' : "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 = Two giant resource companies make up a big chunk of the Brazilian Bovespa. They are PetroBras (NYSE: PBR), with a market cap of $163.44 billion, and miner Vale (NYSE: VALE), which has a market cap of $178.95 billion. PBR shares have risen 1.47% thus far today and VALE is trading 0.77% higher at $34.03. This article was originally published on Benzinga, and is republished here with permission. EOT; foreach( getImg($str) as $url) { get_photo($url); }?
相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
上一篇: 我的求职面试真实感悟
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论