<?php
$p = '/<img .*?src=[\'|\"](.+?)[\'|\"].*? alt="PHP code to extract the first picture on the page as a thumbnail" >/i';
preg_match_all($p,$str,$match);
print_r($match[1][0]);
?>
Copy after login
<img alt="PHP code to extract the first picture on the page as a thumbnail"http://usr.im/200x60?bg=3498DB&text=tool.lu" class="img" />
结果为:http://usr.im/200x60?bg=3498DB&text=tool.lu
<img alt="PHP code to extract the first picture on the page as a thumbnail"http://img.mukewang.com/user/55c877240001291602790279-80-80.jpg" class="img" />
结果为:http://img.mukewang.com/user/55c877240001291602790279-80-80.jpg
Copy after login