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
$a[0] = 'John Doe'; $a[1] = 'Jason statham'; $a[2] = 'Thomas Anderson'; $size = count($a); foreach($a as $key=>$name){ $result .= $name; if($size > $key+1) $result .=', '; } echo $result;