need help with sorting words by utf-8. For example, we have 5 cities from Belgium.
$array = array(\'Borgloon\',\'Thuin\',\'Lennik\',\'Éghezée\',\'Aubel\');
s
There are great answers here, but this is a dead simple solution for most situations.
function globalsort($array, $in = 'UTF-8', $out = 'ASCII//TRANSLIT//IGNORE')
{
return usort($array, function ($a, $b) use ($in, $out) {
$a = @iconv($in, $out, $a);
$b = @iconv($in, $out, $b);
return strnatcasecmp($a, $b);
});
}
And use it like so:
globalsort($array);