开发者

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

开发者 https://www.devze.com 2023-02-15 10:39 出处:网络
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

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

精彩评论

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