3v4l.org

run code in 300+ PHP versions simultaneously
<?php function printTable($matrix) { $table = '<table border="1">'; $rows = count($matrix); for ($i = 0; $i < $rows; $i++) { $cols = count($matrix[$i]); $table .= '<tr>'; for ($j = 0; $j < $cols; $j++) { $table .= '<td>' . $matrix[$i][$j] . '</td>'; } $table .= '</tr>'; } $table .= '</table>'; echo $table; } function createMatrix($x, $y) { $matrix = []; for ($i = 0; $i < $x; $i++) { $row = []; for ($j = 0; $j < $y; $j++) { $row[] = rand(1, 100); } $matrix[] = $row; } return $matrix; } function transposeArray($array) { $i = 0; $transpose = []; while ($columns = array_column($array, $i++)) { $transpose[] = $columns; } return $transpose; } $table = createMatrix(10, 5); echo 'Matrix<br/>'; printTable($table); echo '<br/><br/><br/>'; echo 'Transposed Matrix<br/>'; $table = transposeArray($table); printTable($table);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v9VsV
function name:  (null)
number of ops:  19
compiled vars:  !0 = $table
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   INIT_FCALL                                               'creatematrix'
          1        SEND_VAL                                                 10
          2        SEND_VAL                                                 5
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   54     5        ECHO                                                     'Matrix%3Cbr%2F%3E'
   55     6        INIT_FCALL                                               'printtable'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0          
   56     9        ECHO                                                     '%3Cbr%2F%3E%3Cbr%2F%3E%3Cbr%2F%3E'
   57    10        ECHO                                                     'Transposed+Matrix%3Cbr%2F%3E'
   58    11        INIT_FCALL                                               'transposearray'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $4      
         14        ASSIGN                                                   !0, $4
   59    15        INIT_FCALL                                               'printtable'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Function printtable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 6
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 12
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
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 12
Branch analysis from position: 20
Branch analysis from position: 12
filename:       /in/v9VsV
function name:  printTable
number of ops:  27
compiled vars:  !0 = $matrix, !1 = $table, !2 = $rows, !3 = $i, !4 = $cols, !5 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, '%3Ctable+border%3D%221%22%3E'
    6     2        COUNT                                            ~7      !0
          3        ASSIGN                                                   !2, ~7
    7     4        ASSIGN                                                   !3, 0
          5      > JMP                                                      ->22
    9     6    >   FETCH_DIM_R                                      ~10     !0, !3
          7        COUNT                                            ~11     ~10
          8        ASSIGN                                                   !4, ~11
   10     9        ASSIGN_OP                                     8          !1, '%3Ctr%3E'
   11    10        ASSIGN                                                   !5, 0
         11      > JMP                                                      ->18
   13    12    >   FETCH_DIM_R                                      ~15     !0, !3
         13        FETCH_DIM_R                                      ~16     ~15, !5
         14        CONCAT                                           ~17     '%3Ctd%3E', ~16
         15        CONCAT                                           ~18     ~17, '%3C%2Ftd%3E'
         16        ASSIGN_OP                                     8          !1, ~18
   11    17        PRE_INC                                                  !5
         18    >   IS_SMALLER                                               !5, !4
         19      > JMPNZ                                                    ~21, ->12
   15    20    >   ASSIGN_OP                                     8          !1, '%3C%2Ftr%3E'
    7    21        PRE_INC                                                  !3
         22    >   IS_SMALLER                                               !3, !2
         23      > JMPNZ                                                    ~24, ->6
   17    24    >   ASSIGN_OP                                     8          !1, '%3C%2Ftable%3E'
   18    25        ECHO                                                     !1
   21    26      > RETURN                                                   null

End of function printtable

Function creatematrix:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 5
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 8
Branch analysis from position: 17
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: 8
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 8
Branch analysis from position: 17
Branch analysis from position: 8
filename:       /in/v9VsV
function name:  createMatrix
number of ops:  24
compiled vars:  !0 = $x, !1 = $y, !2 = $matrix, !3 = $i, !4 = $row, !5 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        ASSIGN                                                   !2, <array>
   26     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->20
   28     5    >   ASSIGN                                                   !4, <array>
   29     6        ASSIGN                                                   !5, 0
          7      > JMP                                                      ->15
   31     8    >   INIT_FCALL                                               'rand'
          9        SEND_VAL                                                 1
         10        SEND_VAL                                                 100
         11        DO_ICALL                                         $11     
         12        ASSIGN_DIM                                               !4
         13        OP_DATA                                                  $11
   29    14        PRE_INC                                                  !5
         15    >   IS_SMALLER                                               !5, !1
         16      > JMPNZ                                                    ~13, ->8
   33    17    >   ASSIGN_DIM                                               !2
         18        OP_DATA                                                  !4
   26    19        PRE_INC                                                  !3
         20    >   IS_SMALLER                                               !3, !0
         21      > JMPNZ                                                    ~16, ->5
   36    22    > > RETURN                                                   !2
   37    23*     > RETURN                                                   null

End of function creatematrix

Function transposearray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 4
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 4
Branch analysis from position: 13
Branch analysis from position: 4
filename:       /in/v9VsV
function name:  transposeArray
number of ops:  15
compiled vars:  !0 = $array, !1 = $i, !2 = $transpose, !3 = $columns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   43     1        ASSIGN                                                   !1, 0
   44     2        ASSIGN                                                   !2, <array>
   45     3      > JMP                                                      ->6
   47     4    >   ASSIGN_DIM                                               !2
          5        OP_DATA                                                  !3
   45     6    >   INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !0
          8        POST_INC                                         ~7      !1
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                         $8      
         11        ASSIGN                                           ~9      !3, $8
         12      > JMPNZ                                                    ~9, ->4
   50    13    > > RETURN                                                   !2
   51    14*     > RETURN                                                   null

End of function transposearray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.39 ms | 1449 KiB | 19 Q