Codice PHP:
$sep 0;
foreach (...) {
..
$sep++;
if (
$sep%== 0//stampa separatore