3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [1,2,3,4,5]; $cols = 4; $chunks = array_fill(0, $cols, []); $cnt = 0; foreach ($array as $thing) { $chunks[$cnt++ % $cols][] = $thing; } var_dump($chunks); $chunks = array_chunk($array, $cols); $chunks = array_map(null, ...$chunks); var_dump($chunks);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/D9hnD
function name:  (null)
number of ops:  36
compiled vars:  !0 = $array, !1 = $cols, !2 = $chunks, !3 = $cnt, !4 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, 4
    9     2        INIT_FCALL                                               'array_fill'
          3        SEND_VAL                                                 0
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   10     8        ASSIGN                                                   !3, 0
   12     9      > FE_RESET_R                                       $10     !0, ->17
         10    > > FE_FETCH_R                                               $10, !4, ->17
   13    11    >   POST_INC                                         ~11     !3
         12        MOD                                              ~12     ~11, !1
         13        FETCH_DIM_W                                      $13     !2, ~12
         14        ASSIGN_DIM                                               $13
         15        OP_DATA                                                  !4
   12    16      > JMP                                                      ->10
         17    >   FE_FREE                                                  $10
   16    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
   18    21        INIT_FCALL                                               'array_chunk'
         22        SEND_VAR                                                 !0
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $16     
         25        ASSIGN                                                   !2, $16
   19    26        INIT_FCALL                                               'array_map'
         27        SEND_VAL                                                 null
         28        SEND_UNPACK                                              !2
         29        CHECK_UNDEF_ARGS                                         
         30        DO_ICALL                                         $18     
         31        ASSIGN                                                   !2, $18
   20    32        INIT_FCALL                                               'var_dump'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.46 ms | 1396 KiB | 21 Q