3v4l.org

run code in 150+ 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 "\n"; } $i++; } ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Element1, Element2, Element3, Element4, Element5, Element6