Home  >  Article  >  php教程  >  php 图片地址和删除网址部份正则方法

php 图片地址和删除网址部份正则方法

WBOY
WBOYOriginal
2016-06-13 10:03:34896browse

下面方法很简单,我们只要把$tmppath里面所有的以http://开的网站全部去了,


$picpath =preg_replace("/[a-za-z]+://[^ |/|s]*/",'',$tmppath);//去掉网址部分

这个正则表达式是获取字符串中所有的以src src不区分大小的获取所有图片的地址出来,并且保存在$tmpdata[2]中。
 preg_match_all("/src=["|'|s|s]([^|/|>]*){0,}(([^>]*).(gif|jpg|png))/isu",$body,$tmpdata);

$picspath =array_unique($tmpdata[2]);//body中所有图片的地址

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