When I was doing image extraction today, I encountered this situation. The image in an article was extracted as the cover of the article, in this way, the graphic mode looks quite comfortable during the layout, but now this article may contain some expressions. Of course, we cannot extract the src path directly, so if the first one is an emoticon image, we will extract the emoticon image as the cover. At this time, we need to write a clear regular expression to exclude unmatched images. Below is a small column:
The Code is as follows:
$ Contents ='
Fatigue is a kind of enjoyment, which makes us innocent; Bumpy is an experience that makes us really understand life;
Busy is a kind of happiness, so that we do not have time to experience the pain; busy is a kind of happiness,
';
Preg_match ('#
Var_dump ($ matches );
// Running result
/*
Array (size = 2)
0 => string '1 => string 'HTTP: // www.php.net/uploads/image/20140420/13979336108926.jpg' (length = 66)
*/