Home > Backend Development > PHP Tutorial > Get the link to the first image in the article

Get the link to the first image in the article

WBOY
Release: 2016-07-25 08:50:26
Original
947 people have browsed it
  1. function pickupImage($html) {
  2. preg_match_all('//U', $html, $matches, PREG_PATTERN_ORDER);
  3. if(count($matches[0]) > 0) {
  4. foreach ($matches[0] as $match)
  5. {
  6. preg_match('/src="(.+)"/U', $match, $src);
  7. return $src[1];
  8. }
  9. }
  10. else
  11. return '';
  12. }
复制代码


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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template