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>
Output for git.master, git.master_jit, rfc.property-hooks
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 <div class="wrapper"> <div class='cell'><h1>cat1</h1><span>prod1</span><span>prod2</span></div><div class='cell'><h1>cat2</h1><span>prod3</span></div><div class='cell'><h1>cat3</h1><span></span></div></div> <style> .wrapper{ display: table; } .cell { display: table-cell; border: 1px solid red; padding: 10px; text-align: center; } .cell span { display: block; } </style>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
53.43 ms | 402 KiB | 8 Q