Possible Duplicate:
PHP, Echoing an array into a string of comma seperated values
This seems like it should be fairly straight-forward for experienced PHP coders... which I'm not.
This is what I have so far:
<?php echo $cfs->get_labels('name'); ?>: <?php $values = $cfs->get('name');
foreach($values as $value => $label) {echo $value . ', ';}
?>
How could I avoid having a comma printed on the last value in something like this?
I've referred to this and similar, but can't seem to crack it.
You can use echo implode(',', $values);
instead of the foreach loop.
EDIT: whoops, I just noticed you output the keys, so for that you can use:
echo implode(',', array_keys($values));