Home > Backend Development > PHP Tutorial > A simple way to determine whether there are images in an article using PHP_PHP Tutorial

A simple way to determine whether there are images in an article using PHP_PHP Tutorial

WBOY
Release: 2016-07-13 10:21:58
Original
876 people have browsed it

A simple method for PHP to determine whether there are pictures in an article

This article mainly introduces the method for PHP to determine whether there are pictures in an article. It is a very practical function. Friends who need it can For reference

The PHP program in this article is used to determine whether the article contains pictures. The main implementation idea is to use preg_match to check whether there is a matching "

" in the content.

Stop talking nonsense, here is the main implementation code:

$url="http://XXXXX/article/012.html";

 $content=file_get_contents($url); //Read article page source code

 if(preg_match("/

echo "Picture detected";

 }else{

echo "No image found";

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852815.htmlTechArticleA simple method for PHP to determine whether there are pictures in an article. This article mainly introduces PHP to determine whether there are pictures in an article. Method, very practical function, friends who need it can refer to the PH of this article...
Related labels:
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