3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! $data = array( array('a', 'b', 'c', 'd', 'e'), array('f', 'g', 'h', 'i', 'j'), array('k', 'l', 'm', 'n', 'o'), array('p', 'q', 'r') ); echo "<pre>"; //print_r(array_chunk($data,4,true)); //die(); /*$width = count($data[0]); // 5 $height = count($data); // 4 $total = $width * $height; // 20 $new_data = array(); for($i = 0; $i < $total; $i++) { $old_x = floor($i % $width); // integer division $old_y = $i / $width; // modulo $new_x = $i % $height; // modulo $new_y = floor($i / $height); // integer division if (!isset($new_data[$new_x])) { $new_data[$new_x] = array(); } if (isset($data[$old_x][$old_y])) { $new_data[$new_x][$new_y] = $data[$old_x][$old_y]; } } print_r($new_data);*/ function flip90($arr, $lineHeight) { $tbl = array(); $index = 0; $counter = 1; for($i = 0; $i < count($arr); $i++) { if($counter > $lineHeight) { $index++; $counter = 1; } if($counter <= $lineHeight) { $tbl[$index][$counter] = $arr[$i]; $counter++; } } return $tbl; } $flipped = flip90($data, 5); echo "<pre>"; var_dump($flipped); echo "<pre>";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ttlqr
function name:  (null)
number of ops:  13
compiled vars:  !0 = $data, !1 = $flipped
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ECHO                                                     '%3Cpre%3E'
   63     2        INIT_FCALL                                               'flip90'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 5
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   64     7        ECHO                                                     '%3Cpre%3E'
   65     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   66    11        ECHO                                                     '%3Cpre%3E'
         12      > RETURN                                                   1

Function flip90:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
Branch analysis from position: 7
Branch analysis from position: 18
Branch analysis from position: 11
filename:       /in/Ttlqr
function name:  flip90
number of ops:  24
compiled vars:  !0 = $arr, !1 = $lineHeight, !2 = $tbl, !3 = $index, !4 = $counter, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   37     2        ASSIGN                                                   !2, <array>
   39     3        ASSIGN                                                   !3, 0
   40     4        ASSIGN                                                   !4, 1
   43     5        ASSIGN                                                   !5, 0
          6      > JMP                                                      ->19
   45     7    >   IS_SMALLER                                               !1, !4
          8      > JMPZ                                                     ~10, ->11
   47     9    >   PRE_INC                                                  !3
   48    10        ASSIGN                                                   !4, 1
   51    11    >   IS_SMALLER_OR_EQUAL                                      !4, !1
         12      > JMPZ                                                     ~13, ->18
   53    13    >   FETCH_DIM_R                                      ~16     !0, !5
         14        FETCH_DIM_W                                      $14     !2, !3
         15        ASSIGN_DIM                                               $14, !4
         16        OP_DATA                                                  ~16
   55    17        PRE_INC                                                  !4
   43    18    >   PRE_INC                                                  !5
         19    >   COUNT                                            ~19     !0
         20        IS_SMALLER                                               !5, ~19
         21      > JMPNZ                                                    ~20, ->7
   60    22    > > RETURN                                                   !2
   61    23*     > RETURN                                                   null

End of function flip90

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.39 ms | 1402 KiB | 16 Q