3v4l.org

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

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

End of function swap

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.84 ms | 1403 KiB | 16 Q