I am trying to check two sentences in greek equal with this function:
private function process_line_three($target_line_three,$case_line_three){
$target_line_three=trim($target_line_three);
$case_line_three=trim($case_line_three);
echo "<br/><br/>";
var_dump($case_line_three);
echo "<br/><br/>";
echo mb_detect_encoding($target_line_three);
echo "<br/><br/>";
echo mb_detect_encoding($case_line_three);
//$this->print_chars_not_equal($target_line_three,$case_line_three);
return strcasecmp($target_line_three, $case_line_three)==0;
}
When I pass them the following two strings I get this:
Line 3: case Συνδέσου με χιλιάδες ανθρώπους Παρακολούθησε & δράσε ζωντανά 24/7==Συνδέσου με χιλιάδες ανθρώπους Παρακολούθησε & δράσε ζωντανά 24/7
But equality fails here.. i return false on that result, even though both sentences are similar.. why is that so?
UPDATE :
var_dump($case_line_three); string(117) “Συνδέσου με χιλιάδες
ανθρώπους Παρακολούθησε & δράσε ζωντανά 24/7”
meanwhile, i am trying to find an encoding issue
UPDATE 2:
the output is:
string(117) "Συνδέσου με χιλιάδες ανθρώπους Παρακολούθησε & δράσε ζωντανά 24/7"
UTF-8
UTF-8
both characters are utf
UPDATE 3
output when I write to a file:
Συνδέσου με χιλιάδες ανθρώπους Παρακολούθησε & δράσε ζωντανά 24/7
Συνδέσου με χιλιάδες ανθρώπους Παρακολούθησε & δράσε ζωντανά 24/7
You could use
strncmpto compare the two strings character for character, stopping when they are not equal. Then you could determine which character(s) is different.levenshteinmight tell you how many characters are different.Strings are equal for me, so it is probably an encoding issue. You could use
mb-detect-encodingto check the encoding of the offending characters http://www.php.net/manual/en/function.mb-detect-encoding.php