How can find out all images given on any page using php?

Hello Everyone!
If you would like to find out all images given in any php pages, then don’t worry i am here tell you all a very simple way for do this.
Example :
1. First you have need to store the page content in a  single PHP variable like given below :

<?php  
// $html is the PHP variable
$html='<div>
  <div><img src="http://0.gravatar.com/avatar/cd67755871cbd4804e8657aafd85862d%3Fsize%3D400px" alt="Raghunath Website Freelancer" /></div>
  <div><img src="http://cslewisinstitute.org/webfm_send/2043" alt="Raghunath Website Developer"  /></div>
</div>';
?>

2. Now we are going to find out all images from $html (PHP) variable :

<?php
preg_match_all('/<img[^>]+>/i',$description, $result); //we have now find all images and store these all image in an array $result
 print_r($result); //print all images
?>

 
Screenshot-1
Enjoy Code! (posted by raghunath)

8 Replies to “How can find out all images given on any page using php?”

  1. Your own blog, “How can find out all images given on
    any page using php? | Raghunath Gurjar” was in fact definitely worth writing a comment down here in the comment section!
    Simply wanted to mention you really did a tremendous job.
    Thanks for your effort -Kay

Leave a Reply

Your email address will not be published. Required fields are marked *