Skip to content
Advertisement

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 of

Completely arbitrary sort order in MySQL with PHP

I have a table in MySQL that I’m accessing from PHP. For example, let’s have a table named THINGS: things.ID – int primary key things.name – varchar things.owner_ID – int for joining with another table My select statement to get what I need might look like: SELECT * FROM things WHERE owner_ID = 99; Pretty straightforward. Now, I’d like users

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. Use @St. John Johnson’s solution if they are strings.

Advertisement