👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
sort php array

There is different ways to sort PHP arrays:


Sort by values:

  • asort(): in ascending order
  • arsort(): in descending order

Sort by keys:

  • ksort(): in ascending order
  • krsort(): in descending order

Sort by user-defined function:

  • uasort(): sort by values
  • uksort(): sort by keys
  • usort(): sort by values (do not maintain key association)

Multidimensional arrays:

  • array_multisort()


Full reference here : https://www.php.net/manual/en/array.sorting.php

More