龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

PHP正则表达式提取字符串中的图片地址

时间:2014-06-26 02:16来源:网络整理 作者:网络 点击:
分享到:
PHP正则表达式提取字符串中的图片地址 ```{php}$str=#39;lt;p style=quot;padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 200%;quot;gt;lt;img border=quot;0quot; src=quot;upfiles/2009/07/1246430143_4.jpgquot; alt=qu
$str='<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>';

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

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

print_r($match);

精彩图集

赞助商链接