<?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++;
}
?>