3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array('f1', 'f2', 'f3'), array('s1', 's2', 's3', 's4', 's5'), array('t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8', 't9', 't10', 't11', 't12') ); $max = 12; $each = $max / count($data); $result = array(); foreach ($data as $set) { $start = count($result); while (count($set) > 0 && (count($result)-$start) <= $each) { $result[] = array_shift($set); } } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 11
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
Branch analysis from position: 23
Branch analysis from position: 23
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/qKiAS
function name:  (null)
number of ops:  30
compiled vars:  !0 = $data, !1 = $max, !2 = $each, !3 = $result, !4 = $set, !5 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 12
   10     2        COUNT                                            ~8      !0
          3        DIV                                              ~9      !1, ~8
          4        ASSIGN                                                   !2, ~9
   12     5        ASSIGN                                                   !3, <array>
   13     6      > FE_RESET_R                                       $12     !0, ->25
          7    > > FE_FETCH_R                                               $12, !4, ->25
   14     8    >   COUNT                                            ~13     !3
          9        ASSIGN                                                   !5, ~13
   15    10      > JMP                                                      ->16
   16    11    >   INIT_FCALL                                               'array_shift'
         12        SEND_REF                                                 !4
         13        DO_ICALL                                         $16     
         14        ASSIGN_DIM                                               !3
         15        OP_DATA                                                  $16
   15    16    >   COUNT                                            ~17     !4
         17        IS_SMALLER                                       ~18     0, ~17
         18      > JMPZ_EX                                          ~18     ~18, ->23
         19    >   COUNT                                            ~19     !3
         20        SUB                                              ~20     ~19, !5
         21        IS_SMALLER_OR_EQUAL                              ~21     ~20, !2
         22        BOOL                                             ~18     ~21
         23    > > JMPNZ                                                    ~18, ->11
   13    24    > > JMP                                                      ->7
         25    >   FE_FREE                                                  $12
   20    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.72 ms | 1396 KiB | 17 Q