The problem occurs when sorting equal values ββin an array. Take an array:
$arr = array( 'a' => 1, 'b' => 1, 'c' => 1, 'd' => 1 );
Calling asort($arr, SORT_NUMERIC) in this array will cancel the array . Hence the lines of code:
asort($arr, SORT_NUMERIC); $arr = array_reverse($arr, true);
will return the array to its original order .
So, adding the value above to one value with changing the array as such:
$arr = array( 'a' => 1, 'b' => 1, 'c' => 2, 'd' => 1 ); asort($arr, SORT_NUMERIC); $arr = array_reverse($arr, true);
will look:
Array ( [c] => 2 [a] => 1 [b] => 1 [d] => 1 )
but
arsort($arr, SORT_NUMERIC);
will look:
Array ( [c] => 2 [d] => 1 [b] => 1 [a] => 1 )
Hope this sheds light on the problem ...
keithhatfield
source share