3v4l.org

run code in 300+ PHP versions simultaneously
<?php $teams = array('All-Stars', 'Vets', 'Lightning', 'Bolt'); // HOW MANY WEEKS $weeks = 3; // MAKE ENOUGH ARRAY ELEMENTS FOR THE DISTRIBUTION $array = array_merge($teams, $teams); // POPULATE THE MATCHES ARRAY $matches = array(); while ($weeks) { foreach ($teams as $ptr => $team) { // FIND THE INDEX INTO THE DISTRIBUTION ARRAY $linkt = $ptr + $weeks; // SELECT THE HOME AND AWAY TEAMS $home = $team; $away = $array[$linkt]; $matches[$team][$weeks] = array('home' => $home, 'away' => $away); } // NEXT WEEK $weeks--; } // SORT THE MATCHES SENSIBLY SO WEEK ONE COMES FIRST foreach ($matches as $team => $contests) { ksort($contests); $matches[$team] = $contests; } // ACTIVATE THIS TO SEE WHAT THE $matches ARRAY LOOKS LIKE // print_r($matches); // CREATE THE TABLE OF MATCHUPS $out = NULL; $out .= "<table>"; $out .= PHP_EOL; // CREATE THE HEADERS FOR EACH WEEK $weeknums = end($matches); $out .= "<tr>"; $out .= '<th> Team </th>'; $out .= '<th> v </th>'; $out .= "<th> Team </th>"; $out .= '</tr>'; $out .= PHP_EOL; // CREATE THE MATRIX OF MATCHUPS foreach ($matches as $team => $contests) { $out .= "<form class='form-horizontal' action='".$_SERVER['PHP_SELF']."'d method='post'><tr><td><input type='text' name='teamone' value='$team' readonly></td>"; $out .= "<td> <b>v</b></td>"; foreach ($contests as $week => $matchup) { // print_r($matchup); $out .= "<td> <input type='text' name='teamtwo' value='{$matchup["away"]}' readonly> </td>"; } $out .= "</tr>"; $out .= PHP_EOL; } $out .= "<input class='btn btn-primary' type='submit' name='submit'></form></table>"; $out .= PHP_EOL; foreach ($matches as $team => $contests) { foreach ($contests as $week => $matchup) { print_r($matchup); if(is_array($matchup)){ foreach($matchup as $key => $value){ $home = $matchup['home']; $away = $matchup['away']; echo "INSERT INTO tourn_fixtures(teamone, teamtwo) values ('$home', '$away')\n"; } } } } echo "</pre>"; //echo $out;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 9
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 35
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 74
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 74
Branch analysis from position: 51
2 jumps found. (Code = 77) Position 1 = 62, Position 2 = 70
Branch analysis from position: 62
2 jumps found. (Code = 78) Position 1 = 63, Position 2 = 70
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 70
Branch analysis from position: 74
2 jumps found. (Code = 77) Position 1 = 78, Position 2 = 106
Branch analysis from position: 78
2 jumps found. (Code = 78) Position 1 = 79, Position 2 = 106
Branch analysis from position: 79
2 jumps found. (Code = 77) Position 1 = 81, Position 2 = 104
Branch analysis from position: 81
2 jumps found. (Code = 78) Position 1 = 82, Position 2 = 104
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 103
Branch analysis from position: 88
2 jumps found. (Code = 77) Position 1 = 89, Position 2 = 102
Branch analysis from position: 89
2 jumps found. (Code = 78) Position 1 = 90, Position 2 = 102
Branch analysis from position: 90
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
Branch analysis from position: 102
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 102
Branch analysis from position: 103
Branch analysis from position: 104
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
Branch analysis from position: 104
Branch analysis from position: 106
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 106
Branch analysis from position: 74
Branch analysis from position: 35
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 9
Branch analysis from position: 26
Branch analysis from position: 9
Branch analysis from position: 23
filename:       /in/gFepV
function name:  (null)
number of ops:  109
compiled vars:  !0 = $teams, !1 = $weeks, !2 = $array, !3 = $matches, !4 = $team, !5 = $ptr, !6 = $linkt, !7 = $home, !8 = $away, !9 = $contests, !10 = $out, !11 = $weeknums, !12 = $matchup, !13 = $week, !14 = $value, !15 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 3
    8     2        INIT_FCALL                                               'array_merge'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $18     
          6        ASSIGN                                                   !2, $18
   12     7        ASSIGN                                                   !3, <array>
   13     8      > JMP                                                      ->25
   15     9    > > FE_RESET_R                                       $21     !0, ->23
         10    > > FE_FETCH_R                                       ~22     $21, !4, ->23
         11    >   ASSIGN                                                   !5, ~22
   18    12        ADD                                              ~24     !5, !1
         13        ASSIGN                                                   !6, ~24
   21    14        ASSIGN                                                   !7, !4
   22    15        FETCH_DIM_R                                      ~27     !2, !6
         16        ASSIGN                                                   !8, ~27
   23    17        INIT_ARRAY                                       ~31     !7, 'home'
         18        ADD_ARRAY_ELEMENT                                ~31     !8, 'away'
         19        FETCH_DIM_W                                      $29     !3, !4
         20        ASSIGN_DIM                                               $29, !1
         21        OP_DATA                                                  ~31
   15    22      > JMP                                                      ->10
         23    >   FE_FREE                                                  $21
   27    24        PRE_DEC                                                  !1
   13    25    > > JMPNZ                                                    !1, ->9
   32    26    > > FE_RESET_R                                       $33     !3, ->35
         27    > > FE_FETCH_R                                       ~34     $33, !9, ->35
         28    >   ASSIGN                                                   !4, ~34
   34    29        INIT_FCALL                                               'ksort'
         30        SEND_REF                                                 !9
         31        DO_ICALL                                                 
   35    32        ASSIGN_DIM                                               !3, !4
         33        OP_DATA                                                  !9
   32    34      > JMP                                                      ->27
         35    >   FE_FREE                                                  $33
   44    36        ASSIGN                                                   !10, null
   45    37        ASSIGN_OP                                     8          !10, '%3Ctable%3E'
   46    38        ASSIGN_OP                                     8          !10, '%0A'
   50    39        INIT_FCALL                                               'end'
         40        SEND_REF                                                 !3
         41        DO_ICALL                                         $41     
         42        ASSIGN                                                   !11, $41
   52    43        ASSIGN_OP                                     8          !10, '%3Ctr%3E'
   53    44        ASSIGN_OP                                     8          !10, '%3Cth%3E+Team+%3C%2Fth%3E'
   54    45        ASSIGN_OP                                     8          !10, '%3Cth%3E+v+%3C%2Fth%3E'
   55    46        ASSIGN_OP                                     8          !10, '%3Cth%3E+Team+%3C%2Fth%3E'
   56    47        ASSIGN_OP                                     8          !10, '%3C%2Ftr%3E'
   57    48        ASSIGN_OP                                     8          !10, '%0A'
   61    49      > FE_RESET_R                                       $49     !3, ->74
         50    > > FE_FETCH_R                                       ~50     $49, !9, ->74
         51    >   ASSIGN                                                   !4, ~50
   63    52        FETCH_R                      global              ~52     '_SERVER'
         53        FETCH_DIM_R                                      ~53     ~52, 'PHP_SELF'
         54        CONCAT                                           ~54     '%3Cform+class%3D%27form-horizontal%27+action%3D%27', ~53
         55        ROPE_INIT                                     3  ~56     '%27d+method%3D%27post%27%3E%3Ctr%3E%3Ctd%3E%3Cinput+type%3D%27text%27+name%3D%27teamone%27+value%3D%27'
         56        ROPE_ADD                                      1  ~56     ~56, !4
         57        ROPE_END                                      2  ~55     ~56, '%27+readonly%3E%3C%2Ftd%3E'
         58        CONCAT                                           ~58     ~54, ~55
         59        ASSIGN_OP                                     8          !10, ~58
   64    60        ASSIGN_OP                                     8          !10, '%3Ctd%3E+%3Cb%3Ev%3C%2Fb%3E%3C%2Ftd%3E'
   65    61      > FE_RESET_R                                       $61     !9, ->70
         62    > > FE_FETCH_R                                       ~62     $61, !12, ->70
         63    >   ASSIGN                                                   !13, ~62
   68    64        ROPE_INIT                                     3  ~66     '%3Ctd%3E+%3Cinput+type%3D%27text%27+name%3D%27teamtwo%27+value%3D%27'
         65        FETCH_DIM_R                                      ~64     !12, 'away'
         66        ROPE_ADD                                      1  ~66     ~66, ~64
         67        ROPE_END                                      2  ~65     ~66, '%27+readonly%3E+%3C%2Ftd%3E'
         68        ASSIGN_OP                                     8          !10, ~65
   65    69      > JMP                                                      ->62
         70    >   FE_FREE                                                  $61
   70    71        ASSIGN_OP                                     8          !10, '%3C%2Ftr%3E'
   71    72        ASSIGN_OP                                     8          !10, '%0A'
   61    73      > JMP                                                      ->50
         74    >   FE_FREE                                                  $49
   73    75        ASSIGN_OP                                     8          !10, '%3Cinput+class%3D%27btn+btn-primary%27+type%3D%27submit%27+name%3D%27submit%27%3E%3C%2Fform%3E%3C%2Ftable%3E'
   74    76        ASSIGN_OP                                     8          !10, '%0A'
   76    77      > FE_RESET_R                                       $73     !3, ->106
         78    > > FE_FETCH_R                                       ~74     $73, !9, ->106
         79    >   ASSIGN                                                   !4, ~74
   78    80      > FE_RESET_R                                       $76     !9, ->104
         81    > > FE_FETCH_R                                       ~77     $76, !12, ->104
         82    >   ASSIGN                                                   !13, ~77
   80    83        INIT_FCALL                                               'print_r'
         84        SEND_VAR                                                 !12
         85        DO_ICALL                                                 
   81    86        TYPE_CHECK                                  128          !12
         87      > JMPZ                                                     ~80, ->103
   82    88    > > FE_RESET_R                                       $81     !12, ->102
         89    > > FE_FETCH_R                                       ~82     $81, !14, ->102
         90    >   ASSIGN                                                   !15, ~82
   83    91        FETCH_DIM_R                                      ~84     !12, 'home'
         92        ASSIGN                                                   !7, ~84
   84    93        FETCH_DIM_R                                      ~86     !12, 'away'
         94        ASSIGN                                                   !8, ~86
   86    95        ROPE_INIT                                     5  ~89     'INSERT+INTO+tourn_fixtures%28teamone%2C+teamtwo%29+values+%28%27'
         96        ROPE_ADD                                      1  ~89     ~89, !7
         97        ROPE_ADD                                      2  ~89     ~89, '%27%2C+%27'
         98        ROPE_ADD                                      3  ~89     ~89, !8
         99        ROPE_END                                      4  ~88     ~89, '%27%29%0A'
        100        ECHO                                                     ~88
   82   101      > JMP                                                      ->89
        102    >   FE_FREE                                                  $81
   78   103    > > JMP                                                      ->81
        104    >   FE_FREE                                                  $76
   76   105      > JMP                                                      ->78
        106    >   FE_FREE                                                  $73
   93   107        ECHO                                                     '%3C%2Fpre%3E'
   95   108      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.84 ms | 1413 KiB | 21 Q