PHP ksort seems to be unaffected by setlocale

I am given an array that needs to be sorted by its key (associative array), and it may contain some accented characters (à, è, ì, etc.). If it helps anyone, I know the language to be used, so I should be able to set the language in theory. So my original theory was to do it like this:

setlocale(LC_COLLATE, 'fre');
ksort($array, SORT_LOCALE_STRING);

      

It's not like how ksort works at all - accented characters are always in alphabetical order, when I think they should at least come after normal characters. For example, "everyone" will come after "everyone", but not after "justice." So then I started looking in collator but couldn't find a way to sort by array keys. If anyone has any ideas, we would be very grateful.

+1


source to share


1 answer


Is it on a Windows or Linux (or Mac) server? I believe the language codes are slightly different on Windows ... eg. "nl_NL" on Linux and "nld_nld" on Windows.



+2


source







All Articles