Sorting 2d-array in PHP by value -
this question has answer here:
- how can sort arrays , data in php? 7 answers
i have code :
$diagnose[$count][$row['result']];
i need sort array value of [$count]
as understand, want sort array key value ($count
).
you should use ksort()
(low high) or krsort()
(high low). sorts array key, maintaining key data correlations.
example:
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); ksort($fruits);
in case should be:
ksort($diagnose);
to sort value use asort()
.
find out more here sorting functions: http://php.net/manual/en/array.sorting.php
Comments
Post a Comment