Home >Backend Development >PHP Tutorial >PHP image address and deletion of URL part regular method_PHP tutorial

PHP image address and deletion of URL part regular method_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 16:59:01860browse

The following method is very simple, we only need to delete all the websites opened with http:// in $tmppath,


$picpath =preg_replace("/[a-za-z]+://[^ |/|s]*/",'',$tmppath);//Remove the URL part

This regular expression is to get all the addresses of all pictures in the string using src src regardless of size, and save them in $tmpdata[2].
preg_match_all("/src=["|'|s|s]([^|/|>]*){0,}(([^>]*).(gif|jpg|png))/isu ",$body,$tmpdata);

$picspath =array_unique($tmpdata[2]);//The addresses of all pictures in the body

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631340.htmlTechArticleThe following method is very simple, we only need to delete all the websites opened with http:// in $tmppath , $picpath =preg_replace(/[a-za-z]+://[^ |/|s]*/,'',$tmppath);//Remove the URL part...
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