<?php

// Include the getConfig and getXML functions used for data retrieval.

include('includes/functions.php');
    
function 
station_to_html($station){

    
// Get the XML data from the weather station passed to the function.

    
$data getXML($station);
    
    
// Create XML object from XML data pulled in.
    
    
$xml = new simpleXMLElement($data);
    
    
// Add units onto the appropriate variables.

    
if($xml->temp_c=='NA'$temp 'N/A'; else $temp $xml->temp_c.'&deg;C';
    if(
$xml->windchill_c=='NA'$chill 'N/A'; else $chill $xml->windchill_c.'&deg;C';
    if(
$xml->wind_mph=='NA'$mph 'N/A'; else $mph $xml->wind_mph.'mph';

    
$html '
                <img src="'
.$xml->icon_url_base.$xml->icon_url_name.'" class="image" alt="'.$xml->image->title.'" />
                Weather: '
.$xml->weather.'<br />
                Temperature: '
.$temp.'<br />
                Wind Chill: '
.$chill.'<br />
                Wind Direction: '
.$xml->wind_dir.'<br />
                Wind Speed: '
.$mph.'
                <span>'
.gmdate('g:ia'strtotime($xml->observation_time_rfc822)).'<span>
            '
;

    return 
$html;
};

echo 
station_to_html($_GET['xml']);

?>