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.
So you have to check the PHP Extension Intl is installed on your server.
If you have it, it should be something like this:
<?php $collator = new Collator('fr_FR'); $collator->sort($array); ?>
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_FR
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_FR.utf8'); asort($array, SORT_LOCALE_STRING); ?>
To use this flag, you will need PHP >= 5.0.2 OR PHP 4.4.0