Home >Backend Development >PHP Tutorial >Example of PHP regular extraction of image addresses that do not contain the specified URL_PHP Tutorial

Example of PHP regular extraction of image addresses that do not contain the specified URL_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:32:00766browse

But now this article may contain some expressions. Of course we cannot directly extract src Lu Jin, so if the first one is an expression picture, the expression picture will be extracted as the cover. At this time we need to write clearly Regular rules are used to exclude unmatched images. Here is a small example:

Copy code The code is as follows:

$contents = '

Tiredness is a kind of enjoyment, leaving us no time to feel empty; ups and downs are an experience, allowing us to truly understand life;
Being busy is a kind of happiness, leaving us no time to experience pain ;Running around is a joy,






preg_match('#
var_dump($matches);

//Run result

/*
array (size=2)
0 => string ' 1 => string 'http://www.jb51.net/uploads/image /20140420/13979336569926.jpg' (length=66)

*/

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/756993.htmlTechArticleBut now this article may contain some expressions, of course we cannot directly extract src Lu Jin, so if the first If the picture is an emoticon picture, the emoticon picture will be extracted as the cover...
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