3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_swap(&$input, $num) { $tmp = $input[0]; $input[0] = $input[$num]; return $input[$num] = $tmp; } $input = [4, 5, 8, 9, 1, 7, 2]; function xsort($oldArray) { $newArray = array(); foreach($oldArray as $arr){ $newArray[] = array_swap($oldArray, $arr); } return $newArray; } var_dump(xsort($input));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZtrIL
function name:  (null)
number of ops:  8
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'xsort'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function array_swap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZtrIL
function name:  array_swap
number of ops:  11
compiled vars:  !0 = $input, !1 = $num, !2 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        FETCH_DIM_R                                      ~3      !0, 0
          3        ASSIGN                                                   !2, ~3
    6     4        FETCH_DIM_R                                      ~6      !0, !1
          5        ASSIGN_DIM                                               !0, 0
          6        OP_DATA                                                  ~6
    7     7        ASSIGN_DIM                                       ~7      !0, !1
          8        OP_DATA                                                  !2
          9      > RETURN                                                   ~7
    8    10*     > RETURN                                                   null

End of function array_swap

Function xsort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/ZtrIL
function name:  xsort
number of ops:  14
compiled vars:  !0 = $oldArray, !1 = $newArray, !2 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ASSIGN                                                   !1, <array>
   15     2      > FE_RESET_R                                       $4      !0, ->11
          3    > > FE_FETCH_R                                               $4, !2, ->11
   16     4    >   INIT_FCALL                                               'array_swap'
          5        SEND_REF                                                 !0
          6        SEND_VAR                                                 !2
          7        DO_FCALL                                      0  $6      
          8        ASSIGN_DIM                                               !1
          9        OP_DATA                                                  $6
   15    10      > JMP                                                      ->3
         11    >   FE_FREE                                                  $4
   18    12      > RETURN                                                   !1
   19    13*     > RETURN                                                   null

End of function xsort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.34 ms | 1403 KiB | 17 Q