Skip to content

Instantly share code, notes, and snippets.

@hedcler
Created July 27, 2012 19:25
Show Gist options
  • Save hedcler/3190012 to your computer and use it in GitHub Desktop.
Save hedcler/3190012 to your computer and use it in GitHub Desktop.
Get first image from content
<?php
$HTML = "";
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $HTML, $matches);
$first_img = $matches [1] [0];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment