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); $chunks2 = array_map(null, ...array_chunk($array, $cols)); var_dump($chunks2, $chunks2 === $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/7p2s3
function name:  (null)
number of ops:  37
compiled vars:  !0 = $array, !1 = $cols, !2 = $chunks, !3 = $cnt, !4 = $thing, !5 = $chunks2
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                                         $8      
          7        ASSIGN                                                   !2, $8
   10     8        ASSIGN                                                   !3, 0
   12     9      > FE_RESET_R                                       $11     !0, ->17
         10    > > FE_FETCH_R                                               $11, !4, ->17
   13    11    >   POST_INC                                         ~12     !3
         12        MOD                                              ~13     ~12, !1
         13        FETCH_DIM_W                                      $14     !2, ~13
         14        ASSIGN_DIM                                               $14
         15        OP_DATA                                                  !4
   12    16      > JMP                                                      ->10
         17    >   FE_FREE                                                  $11
   16    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
   18    21        INIT_FCALL                                               'array_map'
         22        SEND_VAL                                                 null
         23        INIT_FCALL                                               'array_chunk'
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $17     
         27        SEND_UNPACK                                              $17
         28        CHECK_UNDEF_ARGS                                         
         29        DO_ICALL                                         $18     
         30        ASSIGN                                                   !5, $18
   19    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !5
         33        IS_IDENTICAL                                     ~20     !5, !2
         34        SEND_VAL                                                 ~20
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
195.41 ms | 1396 KiB | 21 Q