In your code you are only showing 5 elements, so we know how many will be shown.
// add a counter at the beginning
$counter = 0;
// your loop
foreach ($items as $item) {
// output something for this item
// then
// increment counter
$counter++;
// if the counter is < output a comma
if ($counter < 5) {
echo ', ';
}
}