$array = array(
'2' => 'a',
'5' => 'b',
'1' => 'c',
'5' => 'd',
'3' => 'e'
)
foreach($array as $key => $value){
$array1 = $array;
foreach($array1 as $key1 => $value1){
if($key > $key1){
$result[$key1] = $value1;
}
}
}
print_r($result);
this is my output:
Array
(
[1] => c
[2] => a
[3] => e
)
i am making comparison of key with same key by storing this array in another array, if num > num in this case the maximum number 5(5>5) this condtions fails so 5 is not in the new array. so please can anyone tell me how this will sort or is there any better way. thanks in advance.