- var_dump: documentation ( source)
- mb_strlen: documentation ( source)
- ord: documentation ( source)
<?php
function compare($left, $right) {
if (($length = mb_strlen($left)) != mb_strlen($right)) {
return false;
}
for ($i = 0, $result = 0; $i < $length; $i++) {
$result |= ord($left[$i]) ^ ord($right[$i]);
}
return $result === 0;
}
var_dump(compare('Ð', 'Â'));