PHP Trim last character in array

dyncidiorry

New Member
I am really new with PHP and all I have to do is to take all selected values and print them out separating them with comma, however, I need to drop last comma after last item in list. \[code\]<?php $favoriteFruit = get_post_meta($post->ID, 'Favorite Fruit', false) ?><?php if ($favoriteFruit != null): ?> <attribute key="FavoriteFruit" value="http://stackoverflow.com/questions/11190573/<?php foreach($favoriteFruit as $fruit){ echo $fruit.','; } ?>" /><?php endif ?>\[/code\]This one prints out all items in list and doesn't drop last comma. Any ideas?
 
Back
Top