3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bubble_sort($array){ $size = count($array); for($i=0;$i<$size;$i++){ for($j=0;$j<$size-1-$i;$j++){ if($array[$j+1]<$array[$j]){ swap($array,$j,$j+1); } } } return $array; } function swap($arr,$a,$b){ $temp = $arr[$a]; $arr[$a] = $arr[$b]; $arr[$b] = $temp; } $array = array(1,3,2,8,5,7,4,0); echo '<pre>';print_r($array); $array1 = bubble_sort($array); echo "<pre>";print_r($array1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tjZqF
function name:  (null)
number of ops:  14
compiled vars:  !0 = $array, !1 = $array1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   ASSIGN                                                   !0, <array>
   41     1        ECHO                                                     '%3Cpre%3E'
          2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   43     5        INIT_FCALL                                               'bubble_sort'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        ASSIGN                                                   !1, $4
   45     9        ECHO                                                     '%3Cpre%3E'
         10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function bubble_sort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 5
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 7
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 5
Branch analysis from position: 26
Branch analysis from position: 5
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 7
Branch analysis from position: 23
Branch analysis from position: 7
Branch analysis from position: 18
filename:       /in/tjZqF
function name:  bubble_sort
number of ops:  28
compiled vars:  !0 = $array, !1 = $size, !2 = $i, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        COUNT                                            ~4      !0
          2        ASSIGN                                                   !1, ~4
    8     3        ASSIGN                                                   !2, 0
          4      > JMP                                                      ->24
    9     5    >   ASSIGN                                                   !3, 0
          6      > JMP                                                      ->19
   11     7    >   ADD                                              ~8      !3, 1
          8        FETCH_DIM_R                                      ~9      !0, ~8
          9        FETCH_DIM_R                                      ~10     !0, !3
         10        IS_SMALLER                                               ~9, ~10
         11      > JMPZ                                                     ~11, ->18
   14    12    >   INIT_FCALL_BY_NAME                                       'swap'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAR_EX                                              !3
         15        ADD                                              ~12     !3, 1
         16        SEND_VAL_EX                                              ~12
         17        DO_FCALL                                      0          
    9    18    >   PRE_INC                                                  !3
         19    >   SUB                                              ~15     !1, 1
         20        SUB                                              ~16     ~15, !2
         21        IS_SMALLER                                               !3, ~16
         22      > JMPNZ                                                    ~17, ->7
    8    23    >   PRE_INC                                                  !2
         24    >   IS_SMALLER                                               !2, !1
         25      > JMPNZ                                                    ~19, ->5
   26    26    > > RETURN                                                   !0
   29    27*     > RETURN                                                   null

End of function bubble_sort

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

End of function swap

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.83 ms | 1394 KiB | 16 Q