php array sorting with accents
Use multi-byte string functions. There is a function called strcoll
which seems to suit your needs.
More info:
- On how to sort an array of UTF-8 strings
- How to sort an array of UTF-8 strings?
EDIT: added Peter's working code, below
setlocale(LC_COLLATE, 'sk_SK.utf8');
usort($fb_friends['data'], 'custom_sort');
function custom_sort($a, $b) {
return strcoll ($a['last_name'], $b['last_name']);
}
foreach ($fb_friends['data'] as $friend) {
echo '<br>';
echo $friend['name'];
}