3v4l.org

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

Function array_swap:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/EuiaC
function name:  array_swap
number of ops:  10
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                                               !0, !1
         8        OP_DATA                                                  !2
   8     9      > RETURN                                                   null

End of function array_swap

Function xsort:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
Jump found. Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
Jump found. Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 7
Jump found. Position 1 = -2
Branch analysis from position: 7
filename:       /in/EuiaC
function name:  xsort
number of ops:  10
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, ->7
         3    > > FE_FETCH_R                                               $4, !2, ->7
  16     4    >   ASSIGN_DIM                                               !1
         5        OP_DATA                                                  !2
         6      > JMP                                                      ->3
         7    >   FE_FREE                                                  $4
  18     8      > RETURN                                                   !1
  19     9*     > RETURN                                                   null

End of function xsort

Generated using Vulcan Logic Dumper, using php 7.3.0