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(); $missing = 0; foreach ($data as $set) { $missing += $each; while (count($set) > 0 && $missing > 0) { $result[] = array_shift($set); $missing--; } } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 11
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
Branch analysis from position: 22
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/mLWc8
function name:  (null)
number of ops:  29
compiled vars:  !0 = $data, !1 = $max, !2 = $each, !3 = $result, !4 = $missing, !5 = $set
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 12
   11     2        COUNT                                            ~8      !0
          3        DIV                                              ~9      !1, ~8
          4        ASSIGN                                                   !2, ~9
   12     5        ASSIGN                                                   !3, <array>
   14     6        ASSIGN                                                   !4, 0
   15     7      > FE_RESET_R                                       $13     !0, ->24
          8    > > FE_FETCH_R                                               $13, !5, ->24
   16     9    >   ASSIGN_OP                                     1          !4, !2
   17    10      > JMP                                                      ->17
   18    11    >   INIT_FCALL                                               'array_shift'
         12        SEND_REF                                                 !5
         13        DO_ICALL                                         $16     
         14        ASSIGN_DIM                                               !3
         15        OP_DATA                                                  $16
   19    16        PRE_DEC                                                  !4
   17    17    >   COUNT                                            ~18     !5
         18        IS_SMALLER                                       ~19     0, ~18
         19      > JMPZ_EX                                          ~19     ~19, ->22
         20    >   IS_SMALLER                                       ~20     0, !4
         21        BOOL                                             ~19     ~20
         22    > > JMPNZ                                                    ~19, ->11
   15    23    > > JMP                                                      ->8
         24    >   FE_FREE                                                  $13
   23    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.39 ms | 1396 KiB | 17 Q