Skip to content

Instantly share code, notes, and snippets.

@joshhartman
joshhartman / gist:2271523
Created April 1, 2012 04:54
Yahoo! Weather API Example Using SimpleXML in PHP
<?php
if(isset($_POST['zipcode']) && is_numeric($_POST['zipcode'])){
$zipcode = $_POST['zipcode'];
}else{
$zipcode = '50644';
}
$result = file_get_contents('http://weather.yahooapis.com/forecastrss?p=' . $zipcode . '&u=f');
$xml = simplexml_load_string($result);
//echo htmlspecialchars($result, ENT_QUOTES, 'UTF-8');