3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 1 => [ 'categoryName'=>'Main One', 'title'=>'Title one', 'date'=>'2019-09-01', 'score'=>2500 ], 2 => [ 'categoryName'=>'Main One', 'title'=>'Title two', 'date'=>'2019-09-02', 'score'=>3000 ], 3 => [ 'categoryName'=>'Main Two', 'title'=>'Other title', 'date'=>'2019-09-02', 'score'=>2100 ], 4 => [ 'categoryName'=>'Main Three', 'title'=>'Other title', 'date'=>'2019-09-05', 'score'=>200 ], 5 => [ 'categoryName'=>'Main Three', 'title'=>'Other topic', 'date'=>'2019-09-02', 'score'=>1000 ] ]; $prevMain = ""; $currentMain = ""; $html = "<table border=1><tbody>"; foreach($array as $row): $currentMain = $row["categoryName"]; if($currentMain !== $prevMain) { $prevMain = $row["categoryName"]; $html .= '<tr>' . '<td colspan="2">' . $row['categoryName'] . '</td>' . '<td></td>' . '</tr>'; } $html .='<tr>'. '<td>'.$row['date'] .'</td>'. '<td>'.$row['title'].'</td>'. '<td>'.$row['score'] . '</td>'. '</tr>'; endforeach; $html .= "</tbody></table>"; echo $html;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 32
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 32
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/5X2XQ
function name:  (null)
number of ops:  36
compiled vars:  !0 = $array, !1 = $prevMain, !2 = $currentMain, !3 = $html, !4 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        ASSIGN                                                   !1, ''
   37     2        ASSIGN                                                   !2, ''
   38     3        ASSIGN                                                   !3, '%3Ctable+border%3D1%3E%3Ctbody%3E'
   39     4      > FE_RESET_R                                       $9      !0, ->32
          5    > > FE_FETCH_R                                               $9, !4, ->32
   40     6    >   FETCH_DIM_R                                      ~10     !4, 'categoryName'
          7        ASSIGN                                                   !2, ~10
   41     8        IS_NOT_IDENTICAL                                         !2, !1
          9      > JMPZ                                                     ~12, ->18
   42    10    >   FETCH_DIM_R                                      ~13     !4, 'categoryName'
         11        ASSIGN                                                   !1, ~13
   44    12        FETCH_DIM_R                                      ~15     !4, 'categoryName'
         13        CONCAT                                           ~16     '%3Ctr%3E%3Ctd+colspan%3D%222%22%3E', ~15
         14        CONCAT                                           ~17     ~16, '%3C%2Ftd%3E'
   45    15        CONCAT                                           ~18     ~17, '%3Ctd%3E%3C%2Ftd%3E'
   46    16        CONCAT                                           ~19     ~18, '%3C%2Ftr%3E'
         17        ASSIGN_OP                                     8          !3, ~19
   49    18    >   FETCH_DIM_R                                      ~21     !4, 'date'
         19        CONCAT                                           ~22     '%3Ctr%3E%3Ctd%3E', ~21
         20        CONCAT                                           ~23     ~22, '%3C%2Ftd%3E'
   50    21        CONCAT                                           ~24     ~23, '%3Ctd%3E'
         22        FETCH_DIM_R                                      ~25     !4, 'title'
         23        CONCAT                                           ~26     ~24, ~25
         24        CONCAT                                           ~27     ~26, '%3C%2Ftd%3E'
   51    25        CONCAT                                           ~28     ~27, '%3Ctd%3E'
         26        FETCH_DIM_R                                      ~29     !4, 'score'
         27        CONCAT                                           ~30     ~28, ~29
         28        CONCAT                                           ~31     ~30, '%3C%2Ftd%3E'
   52    29        CONCAT                                           ~32     ~31, '%3C%2Ftr%3E'
         30        ASSIGN_OP                                     8          !3, ~32
   39    31      > JMP                                                      ->5
         32    >   FE_FREE                                                  $9
   55    33        ASSIGN_OP                                     8          !3, '%3C%2Ftbody%3E%3C%2Ftable%3E'
   57    34        ECHO                                                     !3
   58    35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.63 ms | 1002 KiB | 13 Q