Rechercher dans :
Web
Pages francophones
Pages : France
Calendrier
<
>
<
année
>
setlocale(LC_TIME, "fr_FR"); // ou "fr" $partner = ""; $ville = "FRXX0016"; $vname="Bordeaux"; $jours = 3; $url = "http://xoap.weather.com/weather/local/".$ville."?cc=*&unit=s&dayf=".$jours; // Conversion Fahrenheit->Celsius function f2c($t) { return round(($t-32)*5/9); } // Conversion Pouce de Mercure ->Millibars function p2m($t) { return round(($t)*33.865); } // Conversion Mile->Km function m2k($d) { return round(($d)*1.609); } // Conversion indice UV US -> FR function indiceus2fr($indice) { if($indice == 'Low') { echo "Faible"; }elseif($indice == 'Moderate') { echo "Modéré"; }elseif($indice == 'High') { echo "Fort"; }else{ echo "N/A"; } } // Conversion direction vent US->FR function ventus2fr($indice) { if($indice == 'ENE') { echo "d'est nord-est"; }elseif($indice == 'NE') { echo "de nord-est"; }elseif($indice == 'ESE') { echo "d'est sud-est"; }elseif($indice == 'N') { echo "de nord"; }elseif($indice == 'W') { echo "d'ouest"; }elseif($indice == 'E') { echo "d'est"; }elseif($indice == 'S') { echo "de sud"; }else{ echo ""; } } // Lecture d'un fichier XML function lit_xml($chaine,$isFile,$item,$champs) { // on lit le fichier ou la chaîne if($isFile) $chaine = @file_get_contents($chaine); if($chaine) { // on explode sur
$tmp = preg_split("/<\/?".$item.">/",$chaine); // pour chaque
for($i=1;$i
foreach($champs as $champ) { $tmp2 = preg_split("/<\/?".$champ.">/",$tmp[$i]); // on ajoute au tableau $tmp3[$champ][] = trim(@$tmp2[1]); } // et on retourne le tableau return @$tmp3; } } // Extraction primaire $xml = lit_xml($url,true,"day d=.*",array("hi","low","part p=\"d\"","part p=\"n\"","wind","sunr","suns")); $xml_infos = lit_xml($url,true,"cc",array("icon","tmp","flik","hmid","lsup","obst","wind","uv","vis","bar")); // Extraction des icones, messages et du taux d'humidité for($i=0;$i<1;$i++) { $tmp = preg_split("/<\/?s>/",$xml_infos["wind"][$i]); $xml_infos["vvent_now"][$i] = $tmp[1]; $tmp = preg_split("/<\/?t>/",$xml_infos["wind"][$i]); $xml_infos["dvent_now"][$i] = $tmp[1]; $tmp = preg_split("/<\/?i>/",$xml_infos["uv"][$i]); $xml_infos["uv_now"][$i] = $tmp[1]; $tmp = preg_split("/<\/?t>/",$xml_infos["uv"][$i]); $xml_infos["uvechelle_now"][$i] = $tmp[1]; $tmp = preg_split("/<\/?r>/",$xml_infos["bar"][$i]); $xml_infos["pression_now"][$i] = $tmp[1]; } for($i=0;$i<$jours;$i++) { $tmp = preg_split("/<\/?icon>/",$xml["part p=\"d\""][$i]); $xml["icond"][$i] = $tmp[1]; $tmp = preg_split("/<\/?t>/",$xml["part p=\"d\""][$i]); $xml["altd"][$i] = $tmp[1]; $tmp = preg_split("/<\/?hmid>/",$xml["part p=\"d\""][$i]); $xml["hmid"][$i] = $tmp[1]; $tmp = preg_split("/<\/?icon>/",$xml["part p=\"n\""][$i]); $xml["iconn"][$i] = $tmp[1]; $tmp = preg_split("/<\/?t>/",$xml["part p=\"n\""][$i]); $xml["altn"][$i] = $tmp[1]; $tmp = preg_split("/<\/?t>/",$xml["wind"][$i]); $xml["dvent"][$i] = $tmp[1]; $tmp = preg_split("/<\/?s>/",$xml["part p=\"d\""][$i]); $xml["vvent"][$i] = $tmp[1]; } ?> for($i=0;$i<1;$i++) { ?>
Reporté à Bordeaux.
En ce moment