Something is escaping me here, I'm doing the 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 purely 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 (06-30-2015) the condition we have is "Clear Sky", but when I test the following condition:
if(strtolower($condition) == "céu limpo") {
....
}
Returns false (the commands within if are not executed)
But if you do:
$hey = "Céu Limpo";
if(strtolower($hey) == "céu limpo") {
....
}
It already returns true and the code within the condition is already executed. I would like to know why this and how to solve