Today, when I was doing image extraction, I encountered this situation. The image in an article was extracted as the cover of the article, so that the graphic mode looks more comfortable during the layout.
Today, when I was doing image extraction, I encountered this situation. The image in an article was extracted as the cover of the article, so that the graphic mode looks more comfortable during the layout.
But now this article may contain some emotices. Of course, we cannot extract the src path strength directly. In this way, 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.jb51.net/uploads/image/20140420/13979336108926.jpg' (length = 66)
*/
,