3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @author D.D.M. van Zelst * @copyright 2012 */ function scheduler($teams){ if (count($teams)%2 != 0){ array_push($teams,""); } $away = array_splice($teams,(count($teams)/2)); $home = $teams; for ($i=0; $i < count($home)+count($away)-1; $i++){ for ($j=0; $j<count($home); $j++){ $round[$i][$j]["Home"]=$home[$j]; $round[$i][$j]["Away"]=$away[$j]; } if(count($home)+count($away)-1 > 2){ array_unshift($away,array_shift(array_splice($home,1,1))); array_push($home,array_pop($away)); } } return $round; } ?> <?php $members = array("A","B","C","D","E"); ?> <?php $schedule = scheduler($members); ?> <?php foreach($schedule AS $round => $games){ echo "Round: ".($round+1)."\n"; foreach($games AS $play){ echo $play["Home"]." - ".$play["Away"]."\n"; } echo "\n"; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 23
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/WW28B
function name:  (null)
number of ops:  28
compiled vars:  !0 = $members, !1 = $schedule, !2 = $games, !3 = $round, !4 = $play
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ECHO                                                     '%0A'
   28     1        ASSIGN                                                   !0, <array>
   29     2        INIT_FCALL                                               'scheduler'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   30     6        ECHO                                                     '%0A'
   32     7      > FE_RESET_R                                       $8      !1, ->26
          8    > > FE_FETCH_R                                       ~9      $8, !2, ->26
          9    >   ASSIGN                                                   !3, ~9
   33    10        ADD                                              ~11     !3, 1
         11        CONCAT                                           ~12     'Round%3A+', ~11
         12        CONCAT                                           ~13     ~12, '%0A'
         13        ECHO                                                     ~13
   34    14      > FE_RESET_R                                       $14     !2, ->23
         15    > > FE_FETCH_R                                               $14, !4, ->23
   35    16    >   FETCH_DIM_R                                      ~15     !4, 'Home'
         17        CONCAT                                           ~16     ~15, '+-+'
         18        FETCH_DIM_R                                      ~17     !4, 'Away'
         19        CONCAT                                           ~18     ~16, ~17
         20        CONCAT                                           ~19     ~18, '%0A'
         21        ECHO                                                     ~19
   34    22      > JMP                                                      ->15
         23    >   FE_FREE                                                  $14
   37    24        ECHO                                                     '%0A'
   32    25      > JMP                                                      ->8
         26    >   FE_FREE                                                  $8
   39    27      > RETURN                                                   1

Function scheduler:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 19
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 21
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 60
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 19
Branch analysis from position: 67
Branch analysis from position: 19
Branch analysis from position: 60
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 21
Branch analysis from position: 35
Branch analysis from position: 21
Branch analysis from position: 9
filename:       /in/WW28B
function name:  scheduler
number of ops:  69
compiled vars:  !0 = $teams, !1 = $away, !2 = $home, !3 = $i, !4 = $j, !5 = $round
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        COUNT                                            ~6      !0
          2        MOD                                              ~7      ~6, 2
          3        IS_NOT_EQUAL                                             ~7, 0
          4      > JMPZ                                                     ~8, ->9
   10     5    >   INIT_FCALL                                               'array_push'
          6        SEND_REF                                                 !0
          7        SEND_VAL                                                 ''
          8        DO_ICALL                                                 
   12     9    >   INIT_FCALL                                               'array_splice'
         10        SEND_REF                                                 !0
         11        COUNT                                            ~10     !0
         12        DIV                                              ~11     ~10, 2
         13        SEND_VAL                                                 ~11
         14        DO_ICALL                                         $12     
         15        ASSIGN                                                   !1, $12
   13    16        ASSIGN                                                   !2, !0
   14    17        ASSIGN                                                   !3, 0
         18      > JMP                                                      ->61
   15    19    >   ASSIGN                                                   !4, 0
         20      > JMP                                                      ->32
   16    21    >   FETCH_DIM_R                                      ~20     !2, !4
         22        FETCH_DIM_W                                      $17     !5, !3
         23        FETCH_DIM_W                                      $18     $17, !4
         24        ASSIGN_DIM                                               $18, 'Home'
         25        OP_DATA                                                  ~20
   17    26        FETCH_DIM_R                                      ~24     !1, !4
         27        FETCH_DIM_W                                      $21     !5, !3
         28        FETCH_DIM_W                                      $22     $21, !4
         29        ASSIGN_DIM                                               $22, 'Away'
         30        OP_DATA                                                  ~24
   15    31        PRE_INC                                                  !4
         32    >   COUNT                                            ~26     !2
         33        IS_SMALLER                                               !4, ~26
         34      > JMPNZ                                                    ~27, ->21
   19    35    >   COUNT                                            ~28     !2
         36        COUNT                                            ~29     !1
         37        ADD                                              ~30     ~28, ~29
         38        SUB                                              ~31     ~30, 1
         39        IS_SMALLER                                               2, ~31
         40      > JMPZ                                                     ~32, ->60
   20    41    >   INIT_FCALL                                               'array_unshift'
         42        SEND_REF                                                 !1
         43        INIT_FCALL                                               'array_shift'
         44        INIT_FCALL                                               'array_splice'
         45        SEND_REF                                                 !2
         46        SEND_VAL                                                 1
         47        SEND_VAL                                                 1
         48        DO_ICALL                                         $33     
         49        SEND_VAR_NO_REF                               0          $33
         50        DO_ICALL                                         $34     
         51        SEND_VAR                                                 $34
         52        DO_ICALL                                                 
   21    53        INIT_FCALL                                               'array_push'
         54        SEND_REF                                                 !2
         55        INIT_FCALL                                               'array_pop'
         56        SEND_REF                                                 !1
         57        DO_ICALL                                         $36     
         58        SEND_VAR                                                 $36
         59        DO_ICALL                                                 
   14    60    >   PRE_INC                                                  !3
         61    >   COUNT                                            ~39     !2
         62        COUNT                                            ~40     !1
         63        ADD                                              ~41     ~39, ~40
         64        SUB                                              ~42     ~41, 1
         65        IS_SMALLER                                               !3, ~42
         66      > JMPNZ                                                    ~43, ->19
   24    67    > > RETURN                                                   !5
   25    68*     > RETURN                                                   null

End of function scheduler

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.4 ms | 1021 KiB | 19 Q