Home > php教程 > PHP源码 > PHP提取字符串中的图片地址

PHP提取字符串中的图片地址

PHP中文网
Release: 2016-05-25 17:14:08
Original
1139 people have browsed it

[PHP]代码  

$str=&#39;<p style="padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 200%;"><img border="0" src="upfiles/2009/07/1246430143_4.jpg" alt=""/></p><p style="padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 200%;"><img border="0" src="upfiles/2009/07/1246430143_3.jpg" alt=""/></p><p style="padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 200%;"><img border="0" src="upfiles/2009/07/1246430143_1.jpg" alt=""/></p>&#39;;

$pattern="/<[img|IMG].*?src=[\&#39;|\"](.*?(?:[\.gif|\.jpg]))[\&#39;|\"].*?[\/]?>/";

preg_match_all($pattern,$str,$match);

print_r($match);
Copy after login

                   

                   

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template