Home > Backend Development > PHP Tutorial > PHP uses preg_match_all to match pictures in articles

PHP uses preg_match_all to match pictures in articles

WBOY
Release: 2016-07-25 09:05:40
Original
810 people have browsed it
  1. $con = file_get_contents("http://bbs.it-home.org/news/jbxue-1.html");
  2. $pattern="//";
  3. preg_match_all( $pattern,$con,$match);
  4. print_r($match);
  5. ?>
Copy code

Result: Array ( [0] => Array ( [0] => PHP uses preg_match_all to match pictures in articles [1] => PHP uses preg_match_all to match pictures in articles [2] => PHP uses preg_match_all to match pictures in articles ) [1] => Array ( [0] => http://bbs.it-home.org/usr/themes/dddefault/images/logo.png [1] => http://bbs.it-home.org/usr/uploads/2012/09/531656480.jpg [2] => http://bbs.it-home.org/usr/uploads/2012/09/2647136297.jpg ) )

Articles you may be interested in: An example of PHP code matching image address Example of PHP regular matching of date and time (timestamp conversion) php regular expression matching any URL An example of php regular matching code that rewrites the img path of html images PHP regular matching to obtain the code of the domain name in the URL Use preg_replace function to match images and add links php regular expression matching domain name in URL



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