Forum Moderators: coopster
I have a php script for weather and read xml data from weather.com:
_____________________________________
$search=str_replace(" ","+",$_REQUEST['search']);
$search_url = "http://xoap.weather.com/search/search?where=$search";
$fp = fopen($search_url,"r");
while (!feof ($fp))
$xml .= fgets($fp, 4096);
fclose ($fp);
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parse_into_struct($parser,$xml,$values,$index);
xml_parser_free($parser);
$counter=0;
if($index[loc]!=""){
foreach ($index[loc] as $loc){
$location_code[$counter] = $values[$index[loc][$counter]][attributes][id];
$location_name[$counter] = $values[$index[loc][$counter]][value];
$xml="";
$counter++;
}
}
echo $values[$day][attributes][t] . ", " . $values[$day][attributes][dt]; //This show day, Month and date. Like this "Monday, Feb 25"
___________________________________________
Now I want to replace name of day in my language. Like "Lunedi, Feb 25"
How I can do this?
$from = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
$to = array('Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato', 'Domenica');
$day = [url=http://www.php.net/str-replace]str_replace[/url]($from, $to, $values[$day][attributes][t]);
echo $day . ", " . $values[$day][attributes][dt];