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

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

PHP中文网
PHP中文网Original
2016-05-25 17:14:081136browse

[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);

                   

                   

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