3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ [15, 16, 8, 1], [2, 3, 4, 7], [9, 11, 19, 6] ]; function bubbleSortRowCol($arr) { $cols = []; foreach($arr as $row) { bubbleSort($row); } } function bubbleSort($arr) { $sorted = false; while (false === $sorted) { $sorted = true; for ($i = 0; $i < count($arr)-1; ++$i) { $current = $arr[$i]; $next = $arr[$i+1]; if ($next < $current) { $arr[$i] = $next; $arr[$i+1] = $current; $sorted = false; } } } return $arr; } print_r(bubbleSortColRow($arr));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XigoJ
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL_BY_NAME                                       'bubbleSortColRow'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function bubblesortrowcol:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/XigoJ
function name:  bubbleSortRowCol
number of ops:  10
compiled vars:  !0 = $arr, !1 = $cols, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        ASSIGN                                                   !1, <array>
   13     2      > FE_RESET_R                                       $4      !0, ->8
          3    > > FE_FETCH_R                                               $4, !2, ->8
   14     4    >   INIT_FCALL_BY_NAME                                       'bubbleSort'
          5        SEND_VAR_EX                                              !2
          6        DO_FCALL                                      0          
   13     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $4
   17     9      > RETURN                                                   null

End of function bubblesortrowcol

Function bubblesort:
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 = 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 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 6
Branch analysis from position: 24
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 6
Branch analysis from position: 24
Branch analysis from position: 6
Branch analysis from position: 19
filename:       /in/XigoJ
function name:  bubbleSort
number of ops:  28
compiled vars:  !0 = $arr, !1 = $sorted, !2 = $i, !3 = $current, !4 = $next
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN                                                   !1, <false>
   21     2      > JMP                                                      ->24
   22     3    >   ASSIGN                                                   !1, <true>
   23     4        ASSIGN                                                   !2, 0
          5      > JMP                                                      ->20
   24     6    >   FETCH_DIM_R                                      ~8      !0, !2
          7        ASSIGN                                                   !3, ~8
   25     8        ADD                                              ~10     !2, 1
          9        FETCH_DIM_R                                      ~11     !0, ~10
         10        ASSIGN                                                   !4, ~11
   26    11        IS_SMALLER                                               !4, !3
         12      > JMPZ                                                     ~13, ->19
   27    13    >   ASSIGN_DIM                                               !0, !2
         14        OP_DATA                                                  !4
   28    15        ADD                                              ~15     !2, 1
         16        ASSIGN_DIM                                               !0, ~15
         17        OP_DATA                                                  !3
   29    18        ASSIGN                                                   !1, <false>
   23    19    >   PRE_INC                                                  !2
         20    >   COUNT                                            ~19     !0
         21        SUB                                              ~20     ~19, 1
         22        IS_SMALLER                                               !2, ~20
         23      > JMPNZ                                                    ~21, ->6
   21    24    >   TYPE_CHECK                                    4          !1
         25      > JMPNZ                                                    ~22, ->3
   33    26    > > RETURN                                                   !0
   34    27*     > RETURN                                                   null

End of function bubblesort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.16 ms | 1400 KiB | 15 Q