Home  >  Article  >  php教程  >  php 取得文章中图片地址

php 取得文章中图片地址

WBOY
WBOYOriginal
2016-06-08 17:30:031425browse
<script>ec(2);</script>

我这是看看dede里面的一段代码,他是用php正则把html文件的内容中的img src 中的图片地址获取然后再上传到本地服务器中哦,下面我们来看看是如何写的吧.

$body="中国WEB第一站php 取得文章中图片地址";

preg_match_all("/(src|SRC)=["|'| ]{0,}(http://(.*).(gif|jpg|jpeg|png))/isU",$body,$img_array);
$img_array = array_unique($img_array[2]);

echo "捕获的图片:";
print_r($img_array);

输出结果是不能你代码的图片地址呢.

结果.http://www.111cn.net/a.gif

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn