sort php array by index
For a brief overview of the array sorting functions in PHP, see Sorting Arrays in the PHP manual.
You want to use ksort()
, which sorts an array by its keys.
ksort
Sorts an array by key, maintaining key to data correlations. This is useful mainly for associative arrays.