3v4l.org

run code in 300+ PHP versions simultaneously
<?php $borders = [20,40,60,80]; // some test data $rows[] = ["Rpa" => 30, "Rpb" => 14, "Rpc" => 1, "Rpd" => 24]; $rows[] = ["Rpa" => 41, "Rpb" => 33, "Rpc" => 20, "Rpd" => 79]; $grouprows = []; // we'll need some array to re-structure your rows. foreach($rows as $row) { // this is your while($row = $result->fetch_assoc()) $groups = []; // the former columns will be packed into "groups" (1-20, 21-40,..) foreach($row as $column => $value) { foreach($borders as $i => $border) { // check where the value fits in if($value <= $border) { $groups[$border][] = "$column: $value"; break; } } ksort($groups); // sort the groups to be ascending } $grouprows[] = $groups; } // actual output echo "<table border=1> <tr> <th>1-20</th> <th>21-40</th> <th>41-60</th> <th>61-80</th> <th>81-100</th> </tr>\n"; foreach($grouprows as $row) { echo "<tr>\n"; $colcount = 0; foreach($row as $col) { if(is_array($col)) { echo "\t<td>" . implode(",",$col) . "</td>\n"; } else { echo "\t<td></td>\n"; } $colcount++; } for($colcount;$colcount<count($borders);$colcount++) { echo "\t<td></td>\n"; } echo "</tr>\n"; } echo "</table>";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 34
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 34
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 30
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 25
Branch analysis from position: 25
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 30
Branch analysis from position: 34
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 64
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 64
Branch analysis from position: 38
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 55
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 55
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 52
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 57
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 57
Branch analysis from position: 62
Branch analysis from position: 57
Branch analysis from position: 55
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
Branch analysis from position: 34
filename:       /in/SFPBW
function name:  (null)
number of ops:  67
compiled vars:  !0 = $borders, !1 = $rows, !2 = $grouprows, !3 = $row, !4 = $groups, !5 = $value, !6 = $column, !7 = $border, !8 = $i, !9 = $colcount, !10 = $col
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN_DIM                                               !1
          2        OP_DATA                                                  <array>
    6     3        ASSIGN_DIM                                               !1
          4        OP_DATA                                                  <array>
    9     5        ASSIGN                                                   !2, <array>
   10     6      > FE_RESET_R                                       $15     !1, ->34
          7    > > FE_FETCH_R                                               $15, !3, ->34
   11     8    >   ASSIGN                                                   !4, <array>
   12     9      > FE_RESET_R                                       $17     !3, ->30
         10    > > FE_FETCH_R                                       ~18     $17, !5, ->30
         11    >   ASSIGN                                                   !6, ~18
   13    12      > FE_RESET_R                                       $20     !0, ->25
         13    > > FE_FETCH_R                                       ~21     $20, !7, ->25
         14    >   ASSIGN                                                   !8, ~21
   14    15        IS_SMALLER_OR_EQUAL                                      !5, !7
         16      > JMPZ                                                     ~23, ->24
   15    17    >   ROPE_INIT                                     3  ~27     !6
         18        ROPE_ADD                                      1  ~27     ~27, '%3A+'
         19        ROPE_END                                      2  ~26     ~27, !5
         20        FETCH_DIM_W                                      $24     !4, !7
         21        ASSIGN_DIM                                               $24
         22        OP_DATA                                                  ~26
   16    23      > JMP                                                      ->25
   13    24    > > JMP                                                      ->13
         25    >   FE_FREE                                                  $20
   19    26        INIT_FCALL                                               'ksort'
         27        SEND_REF                                                 !4
         28        DO_ICALL                                                 
   12    29      > JMP                                                      ->10
         30    >   FE_FREE                                                  $17
   21    31        ASSIGN_DIM                                               !2
         32        OP_DATA                                                  !4
   10    33      > JMP                                                      ->7
         34    >   FE_FREE                                                  $15
   25    35        ECHO                                                     '%3Ctable+border%3D1%3E%0A++++++++%3Ctr%3E%0A++++++++%3Cth%3E1-20%3C%2Fth%3E+%0A++++++++%3Cth%3E21-40%3C%2Fth%3E%0A++++++++%3Cth%3E41-60%3C%2Fth%3E%0A++++++++%3Cth%3E61-80%3C%2Fth%3E%0A++++++++%3Cth%3E81-100%3C%2Fth%3E%0A++++++++%3C%2Ftr%3E%0A'
   34    36      > FE_RESET_R                                       $31     !2, ->64
         37    > > FE_FETCH_R                                               $31, !3, ->64
   35    38    >   ECHO                                                     '%3Ctr%3E%0A'
   36    39        ASSIGN                                                   !9, 0
   37    40      > FE_RESET_R                                       $33     !3, ->55
         41    > > FE_FETCH_R                                               $33, !10, ->55
   39    42    >   TYPE_CHECK                                  128          !10
         43      > JMPZ                                                     ~34, ->52
   40    44    >   INIT_FCALL                                               'implode'
         45        SEND_VAL                                                 '%2C'
         46        SEND_VAR                                                 !10
         47        DO_ICALL                                         $35     
         48        CONCAT                                           ~36     '%09%3Ctd%3E', $35
         49        CONCAT                                           ~37     ~36, '%3C%2Ftd%3E%0A'
         50        ECHO                                                     ~37
   39    51      > JMP                                                      ->53
   42    52    >   ECHO                                                     '%09%3Ctd%3E%3C%2Ftd%3E%0A'
   44    53    >   PRE_INC                                                  !9
   37    54      > JMP                                                      ->41
         55    >   FE_FREE                                                  $33
   46    56      > JMP                                                      ->59
   47    57    >   ECHO                                                     '%09%3Ctd%3E%3C%2Ftd%3E%0A'
   46    58        PRE_INC                                                  !9
         59    >   COUNT                                            ~40     !0
         60        IS_SMALLER                                               !9, ~40
         61      > JMPNZ                                                    ~41, ->57
   49    62    >   ECHO                                                     '%3C%2Ftr%3E%0A'
   34    63      > JMP                                                      ->37
         64    >   FE_FREE                                                  $31
   51    65        ECHO                                                     '%3C%2Ftable%3E'
         66      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.68 ms | 1020 KiB | 15 Q