[Solved] In PHP, how to sort associative array sorting based on key [closed]
[ad_1] ksort is PHP’s function to sort by key. So to sort an array $arr by its keys, do: ksort($arr); Note that ksort returns a boolean (success or failure), so you shouldn’t do $arr = ksort($arr);. ksort modifies the original array. To sort a multidimensional associative array (say, an associative array of associative arrays) recursively … Read more