3v4l.org

run code in 300+ PHP versions simultaneously
x = SELECT t.titulo as categoria, tb2.titulo as produto FROM categoria LEFT JOIN tb2 ON tb2.id_cat = categoria.id ORDER BY t.titulo ASC <?php $x = array( array('categoria' => 'cat1', 'titulo' => 'prod1'), array('categoria' => 'cat1', 'titulo' => 'prod2'), array('categoria' => 'cat2', 'titulo' => 'prod3'), array('categoria' => 'cat3', 'titulo' => NULL) ); ?> <div class="wrapper"> <?php $previousCat = ''; foreach($x as $produto){ if ($previousCat != $produto['categoria']){ if ($previousCat != '') echo "</div>"; echo "<div class='cell'><h1>" . $produto['categoria'] . "</h1>"; $previousCat = $produto['categoria']; } echo "<span>" . $produto['titulo'] . "</span>"; } if ($previousCat != '') echo "</div>"; ?> </div> <style> .wrapper{ display: table; } .cell { display: table-cell; border: 1px solid red; padding: 10px; text-align: center; } .cell span { display: block; } </style>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 23
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
Branch analysis from position: 18
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 27
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 23
filename:       /in/HTdnr
function name:  (null)
number of ops:  29
compiled vars:  !0 = $x, !1 = $previousCat, !2 = $produto
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     'x+%3D+SELECT+t.titulo+as+categoria%2C+tb2.titulo+as+produto+FROM+categoria%0ALEFT+JOIN+tb2+ON+tb2.id_cat+%3D+categoria.id%0AORDER+BY+t.titulo+ASC%0A%0A'
    7     1        ASSIGN                                                   !0, <array>
   14     2        ECHO                                                     '%0A%3Cdiv+class%3D%22wrapper%22%3E%0A'
   17     3        ASSIGN                                                   !1, ''
   18     4      > FE_RESET_R                                       $5      !0, ->23
          5    > > FE_FETCH_R                                               $5, !2, ->23
   19     6    >   FETCH_DIM_R                                      ~6      !2, 'categoria'
          7        IS_NOT_EQUAL                                             !1, ~6
          8      > JMPZ                                                     ~7, ->18
   20     9    >   IS_NOT_EQUAL                                             !1, ''
         10      > JMPZ                                                     ~8, ->12
   21    11    >   ECHO                                                     '%3C%2Fdiv%3E'
   22    12    >   FETCH_DIM_R                                      ~9      !2, 'categoria'
         13        CONCAT                                           ~10     '%3Cdiv+class%3D%27cell%27%3E%3Ch1%3E', ~9
         14        CONCAT                                           ~11     ~10, '%3C%2Fh1%3E'
         15        ECHO                                                     ~11
   23    16        FETCH_DIM_R                                      ~12     !2, 'categoria'
         17        ASSIGN                                                   !1, ~12
   25    18    >   FETCH_DIM_R                                      ~14     !2, 'titulo'
         19        CONCAT                                           ~15     '%3Cspan%3E', ~14
         20        CONCAT                                           ~16     ~15, '%3C%2Fspan%3E'
         21        ECHO                                                     ~16
   18    22      > JMP                                                      ->5
         23    >   FE_FREE                                                  $5
   27    24        IS_NOT_EQUAL                                             !1, ''
         25      > JMPZ                                                     ~17, ->27
   28    26    >   ECHO                                                     '%3C%2Fdiv%3E'
   30    27    >   ECHO                                                     '%3C%2Fdiv%3E%0A%0A%3Cstyle%3E%0A%09.wrapper%7B%0A%09%09display%3A+table%3B%0A%09%7D%0A%09.cell+%7B%0A%09%09display%3A+table-cell%3B%0A++++++++border%3A+1px+solid+red%3B%0A++++++++padding%3A+10px%3B%0A++++++++text-align%3A+center%3B%0A%09%7D%0A++++.cell+span+%7B%0A++++++++display%3A+block%3B+++%0A++++%7D%0A%3C%2Fstyle%3E'
   45    28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.51 ms | 1399 KiB | 13 Q