PHP How to create comma separated list from array?
Posted
by st4ck0v3rfl0w
on Stack Overflow
See other posts from Stack Overflow
or by st4ck0v3rfl0w
Published on 2010-03-12T19:23:34Z
Indexed on
2010/03/12
19:27 UTC
Read the original article
Hit count: 233
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"
© Stack Overflow or respective owner