fork(1) download
  1. <?php
  2.  
  3. $string = '<a href="index.html" class="bordered-feature-image"><img src="images/3D Logo.jpg" alt="" /></a> <img src="house.png" /> <img src="http://www.google.com/image.gif" alt="" />';
  4.  
  5.  
  6.  
  7. // GRAB THE IMAGES
  8. preg_match_all('~(?<="|\')[A-Z0-9_ /]+\.(?:jpe?g|png)(?=\'|")~i', $string, $images);
  9. $images = $images[0];
  10. print "\nImages From Match:\n"; print_r($images);
  11.  
  12.  
  13. // STORE FILE TYPES AS AN ARRAY
  14. $accepted_image_types = array('jpg', 'jpeg', 'png');
  15.  
  16. preg_match_all('~(?<="|\')[A-Z0-9_ /]+\.(?:'.implode('|', $accepted_image_types).')(?=\'|")~i', $string, $images);
  17. $images = $images[0];
  18. print "\nImages Pulled In From Array:\n"; print_r($images);
  19.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Images From Match:
Array
(
    [0] => images/3D Logo.jpg
    [1] => house.png
)

Images Pulled In From Array:
Array
(
    [0] => images/3D Logo.jpg
    [1] => house.png
)