how to compare two strings ignoring accentuation in php

103

function removeAccents($str) {
    return preg_replace('/[\x{0300}-\x{036f}]/u',"",normalizer_normalize($str,Normalizer::FORM_D));
}

$a = "Jordão";
$b = "Jordao";

var_dump(removeAccents($a) === removeAccents($b));
function removeAccents($str) {
    return preg_replace('/[\x{0300}-\x{036f}]/u',"",normalizer_normalize($str,Normalizer::FORM_D));
}

$a = "joaoaaeeA";
$b = "joãoâàéèÀ";

var_dump(removeAccents($a) === removeAccents($b));

Comments

Submit
0 Comments