<?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('Ð', 'Â'));
- Output for 5.6.0 - 5.6.38, 7.0.0 - 7.0.31, 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- bool(true)
- Output for 5.5.0 - 5.5.38
- bool(false)
preferences:
44.29 ms | 406 KiB | 5 Q