开发者

Store all array values into a single variable as CSV in PHP

I have an array containing numbers 1-5 (sometimes more). All the members in the array can be displayed using the php function foreach. But, how can I display all the members of my array by storing it in a single开发者_StackOverflow variable as csv (like1, 2, 3, 4, 5), and thereby printing that variable only?


You could use the function implode().

For example

$csv_var = implode(', ', $array);


Have a look at the Manual.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜