Home > php教程 > PHP源码 > body text

PHP code to extract the first picture on the page as a thumbnail

大家讲道理
Release: 2016-11-09 14:30:23
Original
1225 people have browsed it

<?php
$p = &#39;/<img .*?src=[\&#39;|\"](.+?)[\&#39;|\"].*? alt="PHP code to extract the first picture on the page as a thumbnail" >/i&#39;;
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


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template