3v4l.org

run code in 300+ PHP versions simultaneously
<?php $games = array(); $players = array_values($players); $tempplayers = $players; $n = count($players); $temp = $players; if (($n / 2) != round(($n / 2), 0)) { $rounds = $n; $games_per_go = ($n - 1) / 2; } else { $rounds = $n - 1; $games_per_go = $n / 2; } $offset = 0; $fixed = array_shift($tempplayers); $teams = $players; function scheduler($teams) { if (count($teams) % 2 != 0) { array_push($teams, "bye"); } $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++) { $games[$i][$j][Home] = $home[$j]; $games[$i][$j][Away] = $away[$j]; } if (count($home) + count($away) - 1 > 2) { array_unshift($away, array_shift(arra($home, 1, 1))); array_push($home, array_pop($away)); } } return $games; } var_dump(scheduler([1,2,3,4,5,6]));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LDsFO
function name:  (null)
number of ops:  39
compiled vars:  !0 = $games, !1 = $players, !2 = $tempplayers, !3 = $n, !4 = $temp, !5 = $rounds, !6 = $games_per_go, !7 = $offset, !8 = $fixed, !9 = $teams
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'array_values'
          2        SEND_VAR                                                 !1
          3        DO_ICALL                                         $11     
          4        ASSIGN                                                   !1, $11
    5     5        ASSIGN                                                   !2, !1
    6     6        COUNT                                            ~14     !1
          7        ASSIGN                                                   !3, ~14
    7     8        ASSIGN                                                   !4, !1
    8     9        DIV                                              ~17     !3, 2
         10        INIT_FCALL                                               'round'
         11        DIV                                              ~18     !3, 2
         12        SEND_VAL                                                 ~18
         13        SEND_VAL                                                 0
         14        DO_ICALL                                         $19     
         15        IS_NOT_EQUAL                                             $19, ~17
         16      > JMPZ                                                     ~20, ->22
    9    17    >   ASSIGN                                                   !5, !3
   10    18        SUB                                              ~22     !3, 1
         19        DIV                                              ~23     ~22, 2
         20        ASSIGN                                                   !6, ~23
    8    21      > JMP                                                      ->26
   12    22    >   SUB                                              ~25     !3, 1
         23        ASSIGN                                                   !5, ~25
   13    24        DIV                                              ~27     !3, 2
         25        ASSIGN                                                   !6, ~27
   16    26    >   ASSIGN                                                   !7, 0
   17    27        INIT_FCALL                                               'array_shift'
         28        SEND_REF                                                 !2
         29        DO_ICALL                                         $30     
         30        ASSIGN                                                   !8, $30
   18    31        ASSIGN                                                   !9, !1
   41    32        INIT_FCALL                                               'var_dump'
         33        INIT_FCALL                                               'scheduler'
         34        SEND_VAL                                                 <array>
         35        DO_FCALL                                      0  $33     
         36        SEND_VAR                                                 $33
         37        DO_ICALL                                                 
         38      > 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 = 63
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 69, Position 2 = 19
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 21
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 62
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 69, Position 2 = 19
Branch analysis from position: 69
Branch analysis from position: 19
Branch analysis from position: 62
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 21
Branch analysis from position: 37
Branch analysis from position: 21
Branch analysis from position: 9
filename:       /in/LDsFO
function name:  scheduler
number of ops:  71
compiled vars:  !0 = $teams, !1 = $away, !2 = $home, !3 = $i, !4 = $j, !5 = $games
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        COUNT                                            ~6      !0
          2        MOD                                              ~7      ~6, 2
          3        IS_NOT_EQUAL                                             ~7, 0
          4      > JMPZ                                                     ~8, ->9
   23     5    >   INIT_FCALL                                               'array_push'
          6        SEND_REF                                                 !0
          7        SEND_VAL                                                 'bye'
          8        DO_ICALL                                                 
   25     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
   26    16        ASSIGN                                                   !2, !0
   27    17        ASSIGN                                                   !3, 0
         18      > JMP                                                      ->63
   28    19    >   ASSIGN                                                   !4, 0
         20      > JMP                                                      ->34
   29    21    >   FETCH_CONSTANT                                   ~19     'Home'
         22        FETCH_DIM_R                                      ~21     !2, !4
         23        FETCH_DIM_W                                      $17     !5, !3
         24        FETCH_DIM_W                                      $18     $17, !4
         25        ASSIGN_DIM                                               $18, ~19
         26        OP_DATA                                                  ~21
   30    27        FETCH_CONSTANT                                   ~24     'Away'
         28        FETCH_DIM_R                                      ~26     !1, !4
         29        FETCH_DIM_W                                      $22     !5, !3
         30        FETCH_DIM_W                                      $23     $22, !4
         31        ASSIGN_DIM                                               $23, ~24
         32        OP_DATA                                                  ~26
   28    33        PRE_INC                                                  !4
         34    >   COUNT                                            ~28     !2
         35        IS_SMALLER                                               !4, ~28
         36      > JMPNZ                                                    ~29, ->21
   32    37    >   COUNT                                            ~30     !2
         38        COUNT                                            ~31     !1
         39        ADD                                              ~32     ~30, ~31
         40        SUB                                              ~33     ~32, 1
         41        IS_SMALLER                                               2, ~33
         42      > JMPZ                                                     ~34, ->62
   33    43    >   INIT_FCALL                                               'array_unshift'
         44        SEND_REF                                                 !1
         45        INIT_FCALL                                               'array_shift'
         46        INIT_FCALL_BY_NAME                                       'arra'
         47        SEND_VAR_EX                                              !2
         48        SEND_VAL_EX                                              1
         49        SEND_VAL_EX                                              1
         50        DO_FCALL                                      0  $35     
         51        SEND_VAR_NO_REF                               0          $35
         52        DO_ICALL                                         $36     
         53        SEND_VAR                                                 $36
         54        DO_ICALL                                                 
   34    55        INIT_FCALL                                               'array_push'
         56        SEND_REF                                                 !2
         57        INIT_FCALL                                               'array_pop'
         58        SEND_REF                                                 !1
         59        DO_ICALL                                         $38     
         60        SEND_VAR                                                 $38
         61        DO_ICALL                                                 
   27    62    >   PRE_INC                                                  !3
         63    >   COUNT                                            ~41     !2
         64        COUNT                                            ~42     !1
         65        ADD                                              ~43     ~41, ~42
         66        SUB                                              ~44     ~43, 1
         67        IS_SMALLER                                               !3, ~44
         68      > JMPNZ                                                    ~45, ->19
   37    69    > > RETURN                                                   !5
   38    70*     > RETURN                                                   null

End of function scheduler

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
301.7 ms | 1029 KiB | 22 Q