3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $labels = array("Element1","Element2","Element3","Element4","Element5","Element6"); $i = 1; foreach($labels as $label) { echo $label; // add a comma if the label is not the last if($i < count($labels)) { echo ", "; } // $i%2 is 0 when $i is even if($i%2==0) { echo "<br />"; // or echo "\n"; } $i++; } ?>
Output for 4.3.0 - 7.2.0
Element1, Element2, <br />Element3, Element4, <br />Element5, Element6<br />