2
Something is escaping me here, I am doing Curl to a weather page, if the results have accents and comparing with exactly the same string in full this condition returns false (not equal). This is merely for testing:
function get_page($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, True);
curl_setopt($curl, CURLOPT_URL, $url);
/*curl_setopt($curl, CURLOPT_TIMEOUT_MS, 1000);*/
$return = curl_exec($curl);
curl_close($curl);
return $return;
}
$weather = get_page("http://www.accuweather.com/pt/pt/cascais/274007/weather-forecast/274007");
preg_match('/<span class="cond">(.*?)<\/span>/s', $weather, $cond);
preg_match('/<strong class="temp">(.*?)<span>/s', $weather, $temp);
$condition = trim($cond[1]); //Céu Limpo (hoje)
$temp = trim($temp[1]); //27 (hoje)
In today’s case (30-06-2015) the condition we have is "Clear Sky", but when I test the following condition:
if(strtolower($condition) == "céu limpo") {
....
}
False returns (if commands are not executed)
But if it does:
$hey = "Céu Limpo";
if(strtolower($hey) == "céu limpo") {
....
}
Already returns true and the code within the condition is already executed. I would like to know why of this and how to solve
of the one
echo $condition
to see what he’s getting– Maicon Carraro
It’s printing "Clear Sky"
– Miguel