is this in PHP? You could trim leading and trailing white space and new lines with trim(), so it would be trim(implode(',', array));. Alternatively, a str_replace() with a search array and empty-string erase could go a long way.

jeremycherfas.10centuries.com.