Tuesday, 17 September 2013

sort array values by key using php

sort array values by key using php

i have an PHP array in the following format,
Array
(
[0] => Array
(
[40] => 2
[80] => 1
[20] => 0
[60] => 0
[100] => 0
)
[1] => Array
(
[60] => 2
[80] => 1
[20] => 0
[40] => 0
[100] => 0
)
)
Expected output is (20=>0,40=>0,60=>2,80=>1 etc) i tried using
array_values and array_combine, but no luck.
How do i sort array by key using PHP.

No comments:

Post a Comment