Mega Code Archive

 
Categories / Php / File Directory
 

Saving a file with file_put_contents()

$zip = 98052; $weather_page = file_get_contents('http://www.demo.com/z.php?inputstring=' . $zip); $page = strstr($weather_page,'Detailed Forecast'); $table_start = strpos($page, '<table'); $table_end  = strpos($page, '</table>') + 8; $forecast = substr($page, $table_start, $table_end - $table_start); print $forecast; file_put_contents("weather-$zip.txt", $forecast);