×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Mark Foster
Added: Jul 13, 2013 10:09 AM
Views: 20
Tags: no tags
  1. $strFirstImage = "";
  2.  
  3. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $strHTMLSourceContent, $ContentImages);
  4.  
  5. $strFirstImage = $ContentImages[1] [0]; // To grab the first image
  6.  
  7. echo $strFirstImage;