What’s the easiest way to sort array with accent ?

Since PHP 5.3 you can use the Internationalization extension ( intl ). It’s a wrapper for ICU library.

I wasn’t able to use it because i got it disable when i compile php.

phpinfo configure

If you have it , it should be something like this.

<?php
$collator = new Collator('fr_CA');
$collator->sort($yourArray);
?>
If its ain't working, try "locale -a" and you will see which one are installed.
If you want to install one :
Ubuntu : /> locale-gen fr_CA
Gentoo : /> Edit the file /etc/locale.gen and run locale-gen (may need sudo)

What can i do without the intl extension ?


<?php
setLocale(LC_COLLATE, 'fr_CA.utf8');
asort($array, SORT_LOCALE_STRING);
?>
To use this flag, you will need PHP >= 5.0.2 OR PHP 4.4.0