I'm trying to get indexes(keys) from the unsorted array but something I'm doing wrong. This is my two arrays:
$unsorted = [1,2,1,14,3,1,3,6,1,13,83,4, 4 ,68];
$sorted = [83,68,14,13,6,4,4,3,3,2,1,1,1,1];
I tried the array_keys()
.The below code is working
$a = array_keys($unsorted,$sorted[0]);
print_r($a);
echo '<br>';
The output
Array ( [0] => 10 )
but inside for loop it is not. please suggest me where I'm doing wrong
for($y=0;$y<sizeOf($sorted);$y++) {
$final_keys = array_keys($unsorted,$sorted[$y]);
//$final[] = $final_two[$y];
}
print_r($final_keys);
The output is
Array ( [0] => 0 [1] => 2 [2] => 5 [3] => 8 )
what I expect is
Array ( [0] => 10 [1] => 13 [2] => 3 [3] => 9 [4] => 7 [5] => 11 [6] => 12 [7] => 4 [8] => 6 [9] => 1 [10] => 0 [11] => 2 [12] => 5 [13] => 8 )