/ Published in: PHP
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 <?php function retrieveYahooWeather($zipCode="84015") { $yahooUrl = "http://weather.yahooapis.com/forecastrss"; $yahooZip = "?p=$zipCode"; $yahooFullUrl = $yahooUrl . $yahooZip; return $returnYahooWeather; } $localZipCode = "84015"; // Clearfield, UT $weatherXmlString = retrieveYahooWeather($localZipCode); $weatherXmlObject = new SimpleXMLElement($weatherXmlString); $currentCondition = $weatherXmlObject->xpath("//yweather:condition"); $currentTemperature = $currentCondition[0]["temp"]; $currentDescription = $currentCondition[0]["text"]; ?>
Comments
                    Subscribe to comments
                
                