Question about data sorting Array (& nbsp; [175377] & gt; 1 & nbsp; [231940] & gt; 2 & nbsp; [192055] & gt; 2 & nbsp; [231723] & gt; 1 & nbsp; [199305] & gt; 1 & nbsp; [171165] & gt; 4 & nbsp; questions about data sorting
Array
(
[175377] => 1
[231940] => 2
[192055] => 2
[231723] => 1
[199305] => 1
[2, 171165] => 4
[220347] => 1
[170288] => 10
[231676] => 1
[228438] => 2
[215878] => 2
[228851] => 1
[194798] => 1
[231220] => 1
[192509] => 1
[231913] => 2
[231731] => 1
[22747] => 1
[171065] => 5
[231922] => 1
[230942] => 15
[231919] => 1
[2, 171397] => 4
[231916] => 1
[209130] => 2
)
How should such arrays be sorted by the value size?
[230942] => 15, [170288] => 10 ......
------ Solution --------------------
There are many PHP array processing functions. for the basic issues such as sorting, PHP developers must have noticed this.
For details, see The ksort function.
Sort the array by key nameHttp://www.php.net/manual/zh/function.ksort.php
Ksort ($ array, SORT_NUMERIC );
------ Solution --------------------
Arsort ($ arr );
------ Solution --------------------
Arsort ($ arr );