Skip to content

Tag: sorting

php array sorting with accents

I am using this to sort according to last name: But – when in last name is accent, e.g. Šiko, Áron, etc, these names are at the end. How can I sort it properly? Answer 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 o…

PHP Sort Array By SubArray Value

I have the following array structure: What is the best way to order the array in an incremental way, based on the optionNumber? So the results look like: Answer Use usort. In PHP ≥5.3, you should use an anonymous function instead: Note that both code above assume $a[‘optionNumber’] is an integer. …