3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $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]; for($y=0;$y<sizeOf($sorted);$y++) { $final_keys = array_keys($unsorted, $sorted[$y]); //$final[] = $final_two[$y]; print_r($final_keys); }
Output for 5.6.38 - 7.3.0rc3
Array ( [0] => 10 ) Array ( [0] => 13 ) Array ( [0] => 3 ) Array ( [0] => 9 ) Array ( [0] => 7 ) Array ( [0] => 11 [1] => 12 ) Array ( [0] => 11 [1] => 12 ) Array ( [0] => 4 [1] => 6 ) Array ( [0] => 4 [1] => 6 ) Array ( [0] => 1 ) Array ( [0] => 0 [1] => 2 [2] => 5 [3] => 8 ) Array ( [0] => 0 [1] => 2 [2] => 5 [3] => 8 ) Array ( [0] => 0 [1] => 2 [2] => 5 [3] => 8 ) Array ( [0] => 0 [1] => 2 [2] => 5 [3] => 8 )