i'd sort array , store indexes array while keeping original 1 in order now.
array ( [0] => 2000 [1] => 2015 [2] => 2004 [3] => 1990 [4] => 1995 [5] => 1965 [6] => 1990 )
so new 1 should this:
array ( [0] => 5 [1] => 3 [2] => 6 [3] => 4 [4] => 0 [5] => 2 [6] => 1 )
create copy of array; use asort
preserve indexes; use array_keys
array containing indexes:
$arr = array(2000,2015,2004,1990,1995,1965,1990); $arr2 = $arr; asort($arr2); $indexes = array_keys($arr2);