3v4l.org

run code in 300+ PHP versions simultaneously
<?php $players=array( "Mickey Mantle", "Babe Ruth", "Yogi Berra", "Lou Gehrig", "Joe DiMaggio", "Derek Jeter", "Whitey Ford", "Roger Maris", "Reggie Jackson" ); $positions=array("P","C","1","2","SS","3","LF","CF","RF"); $batch=array(); echo "<table border=1>"; echo "<tr><th>#</th><th>",implode("</th><th>",$players),"</th></tr>"; for($week=1; $week<11; ++$week){ if($week==9){ foreach($players as $i=>$v){ $batch[$week][$i]=current(array_diff($positions,array_column($batch,$i))); } }elseif($week==10){ shuffle($positions); $batch[$week]=$positions; }else{ // weeks 1 - 8 while(!isset($batch[$week])){ shuffle($positions); $batch[$week]=$positions; if($week>1){ foreach($batch[$week] as $i=>$v){ if(sizeof(array_unique(array_column($batch,$i)))<$week){ // if vertical duplicates unset($batch[$week]); // trash the week, trigger rerun of loop break; // don't bother to assign positions for remaining players } } } } } echo "<tr><th>$week</th><td>",implode("</td><td>",$batch[$week]),"</td></tr>"; } echo "</table>"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 13
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 35
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 33
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 13
Branch analysis from position: 86
Branch analysis from position: 13
Branch analysis from position: 33
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 44
Branch analysis from position: 72
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 69
Branch analysis from position: 51
2 jumps found. (Code = 77) Position 1 = 53, Position 2 = 68
Branch analysis from position: 53
2 jumps found. (Code = 78) Position 1 = 54, Position 2 = 68
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 67
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 44
Branch analysis from position: 72
Branch analysis from position: 44
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 68
Branch analysis from position: 68
Branch analysis from position: 69
filename:       /in/nZYmM
function name:  (null)
number of ops:  88
compiled vars:  !0 = $players, !1 = $positions, !2 = $batch, !3 = $week, !4 = $v, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   14     2        ASSIGN                                                   !2, <array>
   16     3        ECHO                                                     '%3Ctable+border%3D1%3E'
   17     4        ECHO                                                     '%3Ctr%3E%3Cth%3E%23%3C%2Fth%3E%3Cth%3E'
          5        INIT_FCALL                                               'implode'
          6        SEND_VAL                                                 '%3C%2Fth%3E%3Cth%3E'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $9      
          9        ECHO                                                     $9
         10        ECHO                                                     '%3C%2Fth%3E%3C%2Ftr%3E'
   18    11        ASSIGN                                                   !3, 1
         12      > JMP                                                      ->84
   19    13    >   IS_EQUAL                                                 !3, 9
         14      > JMPZ                                                     ~11, ->35
   20    15    > > FE_RESET_R                                       $12     !0, ->33
         16    > > FE_FETCH_R                                       ~13     $12, !4, ->33
         17    >   ASSIGN                                                   !5, ~13
   21    18        INIT_FCALL                                               'current'
         19        INIT_FCALL                                               'array_diff'
         20        SEND_VAR                                                 !1
         21        INIT_FCALL                                               'array_column'
         22        SEND_VAR                                                 !2
         23        SEND_VAR                                                 !5
         24        DO_ICALL                                         $17     
         25        SEND_VAR                                                 $17
         26        DO_ICALL                                         $18     
         27        SEND_VAR                                                 $18
         28        DO_ICALL                                         $19     
         29        FETCH_DIM_W                                      $15     !2, !3
         30        ASSIGN_DIM                                               $15, !5
         31        OP_DATA                                                  $19
   20    32      > JMP                                                      ->16
         33    >   FE_FREE                                                  $12
   19    34      > JMP                                                      ->72
   23    35    >   IS_EQUAL                                                 !3, 10
         36      > JMPZ                                                     ~20, ->43
   24    37    >   INIT_FCALL                                               'shuffle'
         38        SEND_REF                                                 !1
         39        DO_ICALL                                                 
   25    40        ASSIGN_DIM                                               !2, !3
         41        OP_DATA                                                  !1
   23    42      > JMP                                                      ->72
   27    43    > > JMP                                                      ->69
   28    44    >   INIT_FCALL                                               'shuffle'
         45        SEND_REF                                                 !1
         46        DO_ICALL                                                 
   29    47        ASSIGN_DIM                                               !2, !3
         48        OP_DATA                                                  !1
   30    49        IS_SMALLER                                               1, !3
         50      > JMPZ                                                     ~25, ->69
   31    51    >   FETCH_DIM_R                                      ~26     !2, !3
         52      > FE_RESET_R                                       $27     ~26, ->68
         53    > > FE_FETCH_R                                       ~28     $27, !4, ->68
         54    >   ASSIGN                                                   !5, ~28
   32    55        INIT_FCALL                                               'array_unique'
         56        INIT_FCALL                                               'array_column'
         57        SEND_VAR                                                 !2
         58        SEND_VAR                                                 !5
         59        DO_ICALL                                         $30     
         60        SEND_VAR                                                 $30
         61        DO_ICALL                                         $31     
         62        COUNT                                            ~32     $31
         63        IS_SMALLER                                               ~32, !3
         64      > JMPZ                                                     ~33, ->67
   33    65    >   UNSET_DIM                                                !2, !3
   34    66      > JMP                                                      ->68
   31    67    > > JMP                                                      ->53
         68    >   FE_FREE                                                  $27
   27    69    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~34     !2, !3
         70        BOOL_NOT                                         ~35     ~34
         71      > JMPNZ                                                    ~35, ->44
   40    72    >   ROPE_INIT                                     3  ~37     '%3Ctr%3E%3Cth%3E'
         73        ROPE_ADD                                      1  ~37     ~37, !3
         74        ROPE_END                                      2  ~36     ~37, '%3C%2Fth%3E%3Ctd%3E'
         75        ECHO                                                     ~36
         76        INIT_FCALL                                               'implode'
         77        SEND_VAL                                                 '%3C%2Ftd%3E%3Ctd%3E'
         78        FETCH_DIM_R                                      ~39     !2, !3
         79        SEND_VAL                                                 ~39
         80        DO_ICALL                                         $40     
         81        ECHO                                                     $40
         82        ECHO                                                     '%3C%2Ftd%3E%3C%2Ftr%3E'
   18    83        PRE_INC                                                  !3
         84    >   IS_SMALLER                                               !3, 11
         85      > JMPNZ                                                    ~42, ->13
   42    86    >   ECHO                                                     '%3C%2Ftable%3E'
   43    87      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.47 ms | 1025 KiB | 19 Q