PHP提取字符串中的圖片地址spa
$str='<p><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);
結果顯示:code
Array
(
[0] => Array
(
[0] => <img border="0" src="upfiles/2009/07/1246430143_1.jpg" alt=""/>
)blog
[1] => Array
(
[0] => upfiles/2009/07/1246430143_1.jpg
)圖片
)字符串