3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_split(array $array, $size) { $result = []; $i = 0; foreach ($array as $value) { $result[$i++ % $size][] = $value; } return $result; } $datas = array_split([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3); var_dump($datas); foreach($datas as $data) { echo ''. $data[1] .'\n'; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/5IQY3
function name:  (null)
number of ops:  17
compiled vars:  !0 = $datas, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'array_split'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 3
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   15     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   17     8      > FE_RESET_R                                       $5      !0, ->15
          9    > > FE_FETCH_R                                               $5, !1, ->15
   18    10    >   FETCH_DIM_R                                      ~6      !1, 1
         11        CONCAT                                           ~7      '', ~6
         12        CONCAT                                           ~8      ~7, '%5Cn'
         13        ECHO                                                     ~8
   17    14      > JMP                                                      ->9
         15    >   FE_FREE                                                  $5
   20    16      > RETURN                                                   1

Function array_split:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/5IQY3
function name:  array_split
number of ops:  15
compiled vars:  !0 = $array, !1 = $size, !2 = $result, !3 = $i, !4 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3        ASSIGN                                                   !3, 0
    7     4      > FE_RESET_R                                       $7      !0, ->12
          5    > > FE_FETCH_R                                               $7, !4, ->12
    8     6    >   POST_INC                                         ~8      !3
          7        MOD                                              ~9      ~8, !1
          8        FETCH_DIM_W                                      $10     !2, ~9
          9        ASSIGN_DIM                                               $10
         10        OP_DATA                                                  !4
    7    11      > JMP                                                      ->5
         12    >   FE_FREE                                                  $7
   11    13      > RETURN                                                   !2
   12    14*     > RETURN                                                   null

End of function array_split

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.27 ms | 1403 KiB | 16 Q