Skip to content

Instantly share code, notes, and snippets.

@ertankayalar
Created June 22, 2013 13:54
Show Gist options
  • Save ertankayalar/5840949 to your computer and use it in GitHub Desktop.
Save ertankayalar/5840949 to your computer and use it in GitHub Desktop.
extract image from html
<?php
$contenttograbimagefrom = $youroriginalhtmlwithimage;
$firstImage = "";
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $contenttograbimagefrom, $ContentImages);
$firstImage = $ContentImages[1] [0]; // To grab the first image
echo $firstImage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment