PHP gets all the pictures in the web page by regular expression (the repeating value in the array).

time:13-03-24 forum:PHP tools and code
  Reloaded from http://ansonhome.blog.163.com/blog/static/901791902010102434545472/

PHP to get all the pictures in a web page through regular expressions, the functions used are: the file_get_contents () function reads the entire file into a string, the preg_match_all function matches the global regular expression, array_uni The que function removes the repeated values in the array


[code].lt;? PHP
$url=.quot; http://sports.qq.com/photo/? Pgv_ref=aio.quot;
//file_get_contents () function reads the entire file into a string; Local regular expression matching.
preg_match_all (.Quot; /.lt;.#91; ^.gt;.#93; *) \s*src= (.#91; ^'\.quot; >);
$new_arr=array_unique ($matches.#91; 0.#93;); / / / / / / foreach,
foreach ($new_arr as $key) {
echo $key..Quot;

prev:PHP regularly gets the picture and downl... next:PHP filter special characters and SQL an...
post comment
Notice



approved   A 9 year old student corrected the w...   A survey of lonely elderly people in...   Salted pickled vegetables are carcin...   Angels don't give up! The brachless ...   A family of four, 30 years of frugal...
rand   PHP intercepts the class and instanc...   Foreign web design web site construc...   IBM's PHP tutorial article   PHP online remote download   PHP implementation of Web screenshot
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com