<?
// Fetching Data from weather.com
	

	/* editable area */
	//Fill in your Partner ID and ur licence key  and location ID(U obtain it by email when u register at weather.com for FREE !!!!)
	$partner_ID 	= 	"";
	$license_key 	=	 "";
	$loc_id		=	"";
	$length 		=	2;				//forecast in days from 1 to 10 
	/* editable area */
	
	
	
	
	$xml			=	"";
	$url = "http://xoap.weather.com/weather/local/$loc_id?cc=*&dayf=$length&prod=xoap&par=$partner_ID&key=$license_key&unit=m";
	

	$fp = fopen($url,"r");
	while (!feof ($fp))
	$xml .= fgets($fp, 4096);
	fclose ($fp);
	
		
		// XML PARSER LOSLASSEN hrhr
		$parser = xml_parser_create(  ); 
		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);

		// Tag Names und values geben
		xml_parse_into_struct($parser,$xml,$values,$index); 

		// und Tschüss Fileparser (Closedown)
		xml_parser_free($parser);
		
		
		
		//Vorraussagen herausziehen
		
			for ($i=0; $i<$length; $i++)
			{	
				$sunrise[] 		= 	$values[$index['sunr'][$i]]['value'];
				$sunset []			= 	$values[$index['suns'][$i]]['value'];
				$temp_hi[]		= 	$values[$index['hi'][$i]]['value'];
				$temp_low[]		= 	$values[$index['low'][$i]]['value'];
			}
		
			//Icons herausziehen
			for ($i=0; $i<($length*2); $i++)
			{
				$icons[]			=	$values[$index['icon'][$i]]['value'];
			}
		
			//Umschreibungen herausziehen (und unnötige auslassen)
			for ($i=3; $i<($length*5); $i++)
			{		
				$descript[]		= $values[$index['t'][$i]]['value'];
				$i++;
			}
		
		//ENDE VORAUSSAGEN
		
		//Aktuelle Daten
		$act[]		= 	$values[$index['tmp'][0]]['value'];
		$act[]		=	$values[$index['t'][0]]['value'];
		$act[]		=	$values[$index['icon'][0]]['value'];
		
		
		//Zusammenstellen der Inhalte
		$x=0;
		for ($i=0; $i<$length; $i++)	
		{
			
			//Allgemeine Daten
			$day[$i][]		= 	$sunrise[$i];
			$day[$i][]		= 	$sunset[$i];
			
			//AM TAG
			$day[$i][]		= 	$temp_hi[$i];
			$day[$i][]		= 	$descript[$x];
			$day[$i][]		= 	$icons[$x];
			
			//IN DER NACHT	
			$day[$i][]		= 	$temp_low[$i];
			$day[$i][]		= 	$descript[$x+1];
			$day[$i][]		= 	$icons[$x+1];	
		$x+=2;
		}
		
		/*DEBUG
		echo ("<pre>");
		print_r ($act);
		echo ("</pre>");*/
?>