Skip to content

Instantly share code, notes, and snippets.

@jmccartie
Created November 30, 2009 14:55
Show Gist options
  • Save jmccartie/245480 to your computer and use it in GitHub Desktop.
Save jmccartie/245480 to your computer and use it in GitHub Desktop.
<?php
$url="http://weather.yahoo.com/forecast/USMA0009.html";
$file_contents = file_get_contents($url);
$divStart = '<div class="forecast-icon"';
$strEnd = "'); _background-image/* */: none;";
$start = strpos($file_contents, $divStart) + 50;
$end = strpos($file_contents, $strEnd);
$length = $end-$start;
$imagepath=substr($file_contents, $start , $length);
$image=imagecreatefrompng($imagepath);
imagealphablending($image, true);
imagesavealpha($image, true);
header('Content-Type: image/png');
imagepng($image);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment