3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['id' => 1, 'nickname' => 'abc', 'game' => 'abc', 'checkbox' => 1], ['id' => 2, 'nickname' => 'xyz', 'game' => 'zyx', 'checkbox' => 0], ['id' => 5, 'nickname' => 'xyz', 'game' => 'abc', 'checkbox' => 1], ['id' => 6, 'nickname' => 'afg', 'game' => 'zyx', 'checkbox' => 1], ]; // The data must be sorted by the game, that's the key $sortedData = [ ['id' => 1, 'nickname' => 'abc', 'game' => 'abc', 'checkbox' => 1], ['id' => 5, 'nickname' => 'xyz', 'game' => 'abc', 'checkbox' => 1], ['id' => 2, 'nickname' => 'xyz', 'game' => 'zyx', 'checkbox' => 0], ['id' => 6, 'nickname' => 'afg', 'game' => 'zyx', 'checkbox' => 1], ]; // Figure out which game should span how many rows ahead of time foreach ($sortedData as $row) { $gameCounts[$row['game']] ??= 0; $gameCounts[$row['game']]++; } echo '<table border="1">'; echo '<thead>'; echo '<tr>'; foreach (array_keys($sortedData[0]) as $header) { echo '<th>'.$header.'</th>'; } echo '</tr>'; echo '</thead>'; echo '<tbody>'; $previousGame = null; foreach ($sortedData as $row) { echo '<tr>'; foreach ($row as $key => $value) { if ($key === 'game') { // Game changed - span the cell over the correct number of rows if ($previousGame !== $value) { echo '<td rowspan="'.$gameCounts[$value].'">'.$value.'</td>'; $previousGame = $value; } continue; } echo '<td>'.$value.'</td>'; } echo '</tr>'; } echo '</tbody>'; echo '</table>';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 38, Position 2 = 62
Branch analysis from position: 38
2 jumps found. (Code = 78) Position 1 = 39, Position 2 = 62
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 59
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 59
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 55
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 54
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 54
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 59
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
Branch analysis from position: 32
Branch analysis from position: 18
filename:       /in/HqVCU
function name:  (null)
number of ops:  66
compiled vars:  !0 = $data, !1 = $sortedData, !2 = $row, !3 = $gameCounts, !4 = $header, !5 = $previousGame, !6 = $value, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   20     2      > FE_RESET_R                                       $10     !1, ->18
          3    > > FE_FETCH_R                                               $10, !2, ->18
   21     4    >   FETCH_DIM_R                                      ~11     !2, 'game'
          5        COPY_TMP                                         ~12     ~11
          6        FETCH_DIM_IS                                     ~13     !3, ~11
          7        COALESCE                                         ~14     ~13
          8        ASSIGN_DIM                                       ~15     !3, ~12
          9        OP_DATA                                                  0
         10        QM_ASSIGN                                        ~14     ~15
         11      > JMP                                                      ->13
         12*       FREE                                                     ~12
         13    >   FREE                                                     ~14
   22    14        FETCH_DIM_R                                      ~16     !2, 'game'
         15        FETCH_DIM_RW                                     $17     !3, ~16
         16        PRE_INC                                                  $17
   20    17      > JMP                                                      ->3
         18    >   FE_FREE                                                  $10
   25    19        ECHO                                                     '%3Ctable+border%3D%221%22%3E'
   26    20        ECHO                                                     '%3Cthead%3E'
   27    21        ECHO                                                     '%3Ctr%3E'
   28    22        INIT_FCALL                                               'array_keys'
         23        FETCH_DIM_R                                      ~19     !1, 0
         24        SEND_VAL                                                 ~19
         25        DO_ICALL                                         $20     
         26      > FE_RESET_R                                       $21     $20, ->32
         27    > > FE_FETCH_R                                               $21, !4, ->32
   29    28    >   CONCAT                                           ~22     '%3Cth%3E', !4
         29        CONCAT                                           ~23     ~22, '%3C%2Fth%3E'
         30        ECHO                                                     ~23
   28    31      > JMP                                                      ->27
         32    >   FE_FREE                                                  $21
   31    33        ECHO                                                     '%3C%2Ftr%3E'
   32    34        ECHO                                                     '%3C%2Fthead%3E'
   34    35        ECHO                                                     '%3Ctbody%3E'
   35    36        ASSIGN                                                   !5, null
   36    37      > FE_RESET_R                                       $25     !1, ->62
         38    > > FE_FETCH_R                                               $25, !2, ->62
   37    39    >   ECHO                                                     '%3Ctr%3E'
   38    40      > FE_RESET_R                                       $26     !2, ->59
         41    > > FE_FETCH_R                                       ~27     $26, !6, ->59
         42    >   ASSIGN                                                   !7, ~27
   39    43        IS_IDENTICAL                                             !7, 'game'
         44      > JMPZ                                                     ~29, ->55
   40    45    >   IS_NOT_IDENTICAL                                         !5, !6
         46      > JMPZ                                                     ~30, ->54
   41    47    >   FETCH_DIM_R                                      ~31     !3, !6
         48        CONCAT                                           ~32     '%3Ctd+rowspan%3D%22', ~31
         49        CONCAT                                           ~33     ~32, '%22%3E'
         50        CONCAT                                           ~34     ~33, !6
         51        CONCAT                                           ~35     ~34, '%3C%2Ftd%3E'
         52        ECHO                                                     ~35
   42    53        ASSIGN                                                   !5, !6
   45    54    > > JMP                                                      ->41
   48    55    >   CONCAT                                           ~37     '%3Ctd%3E', !6
         56        CONCAT                                           ~38     ~37, '%3C%2Ftd%3E'
         57        ECHO                                                     ~38
   38    58      > JMP                                                      ->41
         59    >   FE_FREE                                                  $26
   50    60        ECHO                                                     '%3C%2Ftr%3E'
   36    61      > JMP                                                      ->38
         62    >   FE_FREE                                                  $25
   52    63        ECHO                                                     '%3C%2Ftbody%3E'
   53    64        ECHO                                                     '%3C%2Ftable%3E'
         65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.74 ms | 1010 KiB | 14 Q