3v4l.org

run code in 300+ PHP versions simultaneously
<?php $matrix = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], ]; /* i from to i/col i%col i&col i/rows 0 = [0][0] => [0][0] 0 0 0 0 1 = [0][1] => [1][0] 0.3 1 1 0.25 2 = [0][2] => [2][0] 0.6 2 2 0.5 3 = [1][0] => [3][0] 1 0 3 0.75 4 = [1][1] => [0][1] 1.3 1 0 1 5 = [1][2] => [1][1] 1.6 2 1 1.25 6 = [2][0] => [2][1] 2 0 2 1.5 7 = [2][1] => [3][1] 2.3 1 3 1.75 8 = [2][2] => [0][2] 2.6 2 0 2 9 = [3][0] => [1][2] 3 0 1 2.25 10 = [3][1] => [2][2] 3.3 1 2 2.5 11 = [3][2] => [3][2] 3.6 2 3 2.75 */ $rows = count($matrix); $cols = count(current($matrix)); $cells = $rows * $cols; $result = $matrix; for ($i = 0; $i < $cells; ++$i) { $result[$i % $rows][$i / $rows] = $matrix[$i / $cols][$i % $cols]; } var_export($result);
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 = 13
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 13
Branch analysis from position: 25
Branch analysis from position: 13
filename:       /in/LJ7LT
function name:  (null)
number of ops:  29
compiled vars:  !0 = $matrix, !1 = $rows, !2 = $cols, !3 = $cells, !4 = $result, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        COUNT                                            ~7      !0
          2        ASSIGN                                                   !1, ~7
   25     3        INIT_FCALL                                               'current'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $9      
          6        COUNT                                            ~10     $9
          7        ASSIGN                                                   !2, ~10
   26     8        MUL                                              ~12     !1, !2
          9        ASSIGN                                                   !3, ~12
   28    10        ASSIGN                                                   !4, !0
   29    11        ASSIGN                                                   !5, 0
         12      > JMP                                                      ->23
   30    13    >   MOD                                              ~16     !5, !1
         14        DIV                                              ~18     !5, !1
         15        DIV                                              ~20     !5, !2
         16        MOD                                              ~22     !5, !2
         17        FETCH_DIM_R                                      ~21     !0, ~20
         18        FETCH_DIM_R                                      ~23     ~21, ~22
         19        FETCH_DIM_W                                      $17     !4, ~16
         20        ASSIGN_DIM                                               $17, ~18
         21        OP_DATA                                                  ~23
   29    22        PRE_INC                                                  !5
         23    >   IS_SMALLER                                               !5, !3
         24      > JMPNZ                                                    ~25, ->13
   33    25    >   INIT_FCALL                                               'var_export'
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.84 ms | 1007 KiB | 15 Q