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

Get the link to the first image in the article

WBOY
WBOYOriginal
2016-07-25 08:50:26884browse
  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. }
复制代码


Statement:
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