sort array with special characters in php

Posted by Enkay on Stack Overflow See other posts from Stack Overflow or by Enkay
Published on 2010-05-24T15:05:55Z Indexed on 2010/05/24 15:11 UTC
Read the original article Hit count: 243

Filed under:
|
|

I have an array I'm trying to asort using php. The problem is that the array has accented characters in it and needs to be sorted using "french" rules.

 cote < côte < coté < côté

I've tried many things, like using php collators, but I get the following error :

PHP Fatal error:  Class 'Collator' not found

I've also tried to set locale but it didn't do anything so I'm not sure I was doing it right, or if I need to isntall the locale. I'm a little confused.

I'm using PHP 5.2.4 if that helps. If I use asort without anything, it puts all the words with accented characters at the end.

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about sorting