PHP 正则截取符合条件的字符串成为数组

 $str2 = '<p>678678<em>111111<img src="http://www.XXX.top/upload/image/20180709/1531139077408405.Png" title="1531139077408405.jpg" alt="平面图.jpg"/><img src="http://www.XXX.top/upload/image/20180709/1531139077408405.jpg" title="1531139077408405.jpg" alt="平面图.jpg"/><img src="http://www.XXX.top/upload/image/20180709/1531139077408405.jpg" title="1531139077408405.jpg" alt="平面图.jpg"/><img src="http://www.XXX.top/upload/image/20180709/1531139077408405.jpg" title="1531139077408405.jpg" alt="平面图.jpg"/></em></p>';
//  preg_match_all("/\"http:[\/]{2}[a-z]+[.]{1}[a-z\d\-]+[.]{1}[a-z\d]*[\/]*[A-Za-z\d]*[\/]*[A-Za-z\d]*\S*\"/",$str2,$array3); 
    preg_match_all("/upload\/\w+\/\w+\/\w+.(jpg|png|jpeg|gif)/i",$str2,$array3); 

print_r($array3); 

 

posted @ 2018-07-13 22:36  西瓜霜  阅读(654)  评论(0编辑  收藏  举报