I\'m using a foreach loop to echo out some values from my database, I need to strip the last comma from the last loop if that makes sense.
My loop is just simple, as
This is what I normally do, add a comma before the item rather than after, while ignoring the first loop.
$i = 0; $string = ''; foreach($array as $item){ $string .= ($i++ ? ',' : '').$item; }