In this chapter, we will go through the following PHP array sort functions:
sort()
- sort arrays in ascending orderrsort()
- sort arrays in descending orderasort()
- sort associative arrays in ascending order, according to the valueksort()
- sort associative arrays in ascending order, according to the keyarsort()
- sort associative arrays in descending order, according to the valuekrsort()
- sort associative arrays in descending order, according to the keyThe following example sorts the elements of the $cars array in ascending alphabetical orde
The following example sorts the elements of the $numbers array in ascending numerical order:
The following example sorts the elements of the $cars array in descending alphabetical order:
The following example sorts the elements of the $numbers array in descending numerical order:
The following example sorts an associative array in ascending order, according to the value:
The following example sorts an associative array in ascending order, according to the key:
The following example sorts an associative array in descending order, according to the value:
The following example sorts an associative array in descending order, according to the key:
Required fields are marked *
Get all latest content delivered to your email free.