3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rgData = [ 3 => 1, 5 => 0, 1 => 2, 9 => 0, 0 => 1, 4 => 2, 2 => 1, 7 => 0, 6 => 0, 8 => 0, ]; $keys = array_keys($rgData); // Sort the array's keys usort($keys, function($a, $b) use($rgData){ $aVal = $rgData[$a]; $bVal = $rgData[$b]; // Compare the values if($aVal === $bVal){ // If they are the same, compare the keys return $a - $b; } // Otherwise compare the values return $aVal - $bVal; }); var_dump($rgData);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MIqU0
function name:  (null)
number of ops:  15
compiled vars:  !0 = $rgData, !1 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   16     1        INIT_FCALL                                               'array_keys'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   19     5        INIT_FCALL                                               'usort'
          6        SEND_REF                                                 !1
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMIqU0%3A19%240'
          8        BIND_LEXICAL                                             ~5, !0
   30     9        SEND_VAL                                                 ~5
         10        DO_ICALL                                                 
   32    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FMIqU0%3A19%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MIqU0
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $a, !1 = $b, !2 = $rgData, !3 = $aVal, !4 = $bVal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   20     3        FETCH_DIM_R                                      ~5      !2, !0
          4        ASSIGN                                                   !3, ~5
   21     5        FETCH_DIM_R                                      ~7      !2, !1
          6        ASSIGN                                                   !4, ~7
   24     7        IS_IDENTICAL                                             !3, !4
          8      > JMPZ                                                     ~9, ->11
   26     9    >   SUB                                              ~10     !0, !1
         10      > RETURN                                                   ~10
   29    11    >   SUB                                              ~11     !3, !4
         12      > RETURN                                                   ~11
   30    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMIqU0%3A19%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.23 ms | 1396 KiB | 19 Q