3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cmp($a, $b) { $x = $GLOBALS['x']; $v1 = $x[$a]; $v2 = $x[$b]; if ($v1 < $v2) { return -1; } elseif ($v1 > $v2) { return 1; } else { return 0; } } $x = array(1 => 1, 2 => 3, 3 => 2); uksort($x, 'cmp'); var_dump($x); // PHP5 //array(3) { [1]=> int(1) [3]=> int(2) [2]=> int(3) } // PHP7 //array(3) { [3]=> int(2) [2]=> int(3) [1]=> int(1) }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ad1pQ
function name:  (null)
number of ops:  9
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'uksort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'cmp'
          4        DO_ICALL                                                 
   19     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   25     8      > RETURN                                                   1

Function cmp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ad1pQ
function name:  cmp
number of ops:  19
compiled vars:  !0 = $a, !1 = $b, !2 = $x, !3 = $v1, !4 = $v2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        FETCH_R                      global              ~5      'GLOBALS'
          3        FETCH_DIM_R                                      ~6      ~5, 'x'
          4        ASSIGN                                                   !2, ~6
    6     5        FETCH_DIM_R                                      ~8      !2, !0
          6        ASSIGN                                                   !3, ~8
    7     7        FETCH_DIM_R                                      ~10     !2, !1
          8        ASSIGN                                                   !4, ~10
    8     9        IS_SMALLER                                               !3, !4
         10      > JMPZ                                                     ~12, ->13
    9    11    > > RETURN                                                   -1
         12*       JMP                                                      ->18
   10    13    >   IS_SMALLER                                               !4, !3
         14      > JMPZ                                                     ~13, ->17
   11    15    > > RETURN                                                   1
         16*       JMP                                                      ->18
   13    17    > > RETURN                                                   0
   15    18*     > RETURN                                                   null

End of function cmp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.94 ms | 1396 KiB | 17 Q