PHP How to create comma separated list from array?
- by st4ck0v3rfl0w
Hi All,
I know how to loop through items of an array using foreach and append a comma, but it's always a pain having to take off the final comma. Is there an easy PHP way of doing it?
$fruit = array('apple', 'banana', 'pear', 'grape');
Ultimately I want
$result = "apple, banana, pear, grape"