echo trim('a,b,c,', ','); // a,b,c
$foo = array();while (/* ... */){ $foo []= $bar['candy'];}echo join(',', $foo);