3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('8','4','5','0','1'); echo '<pre>';print_r($array); function bubble_sort($arr){ for($i=0;$i<count($array);$i++){ for($j=0;$j<count($array)-1-$i;$j++){ if($array[$j+1]<$array[$j]){ swap($array,$j,$j+1); } } } } function swap($arr,$a,$b){ $temp = $arr[$a]; $arr[$a] = $arr[$b]; $arr[$b] = $temp; } $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/dePsb
function name:  (null)
number of ops:  14
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                                                 
   37     5        INIT_FCALL                                               'bubble_sort'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        ASSIGN                                                   !1, $4
   39     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 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 3
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 5
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 3
Branch analysis from position: 26
Branch analysis from position: 3
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 5
Branch analysis from position: 22
Branch analysis from position: 5
Branch analysis from position: 16
filename:       /in/dePsb
function name:  bubble_sort
number of ops:  27
compiled vars:  !0 = $arr, !1 = $i, !2 = $j, !3 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->23
    8     3    >   ASSIGN                                                   !2, 0
          4      > JMP                                                      ->17
   10     5    >   ADD                                              ~6      !2, 1
          6        FETCH_DIM_R                                      ~7      !3, ~6
          7        FETCH_DIM_R                                      ~8      !3, !2
          8        IS_SMALLER                                               ~7, ~8
          9      > JMPZ                                                     ~9, ->16
   13    10    >   INIT_FCALL_BY_NAME                                       'swap'
         11        SEND_VAR_EX                                              !3
         12        SEND_VAR_EX                                              !2
         13        ADD                                              ~10     !2, 1
         14        SEND_VAL_EX                                              ~10
         15        DO_FCALL                                      0          
    8    16    >   PRE_INC                                                  !2
         17    >   COUNT                                            ~13     !3
         18        SUB                                              ~14     ~13, 1
         19        SUB                                              ~15     ~14, !1
         20        IS_SMALLER                                               !2, ~15
         21      > JMPNZ                                                    ~16, ->5
    7    22    >   PRE_INC                                                  !1
         23    >   COUNT                                            ~18     !3
         24        IS_SMALLER                                               !1, ~18
         25      > JMPNZ                                                    ~19, ->3
   26    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/dePsb
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
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   30     3        FETCH_DIM_R                                      ~4      !0, !1
          4        ASSIGN                                                   !3, ~4
   31     5        FETCH_DIM_R                                      ~7      !0, !2
          6        ASSIGN_DIM                                               !0, !1
          7        OP_DATA                                                  ~7
   32     8        ASSIGN_DIM                                               !0, !2
          9        OP_DATA                                                  !3
   35    10      > RETURN                                                   null

End of function swap

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.3 ms | 1403 KiB | 16 Q