PHP提取页面第一张图为缩略图的代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

<?php
$p = '/<img.*?src=[\'|\"](.+?)[\'|\"].*?>/i';
preg_match_all($p,$str,$match);
print_r($match[1][0]);
?>

<img alt="" src="http://usr.im/200x60?bg=3498DB&text=tool.lu" class="img" />
结果为:http://usr.im/200x60?bg=3498DB&text=tool.lu
 
<img alt="" src="http://img.mukewang.com/user/55c877240001291602790279-80-80.jpg" class="img" />
结果为:http://img.mukewang.com/user/55c877240001291602790279-80-80.jpg