如何逗号分隔显示数组的值 [英] How to comma separate the values of an array for display

查看:78
本文介绍了如何逗号分隔显示数组的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜查了PHP.net网站,最初是一些使用了的list()函数的思想,但似乎并没有完成目标:

I have searched the PHP.net site and originally thought of some use for the list() function but doesn't seem to accomplish the goal:

我有一个未知号码存储在单一阵列值

I have an unknown number of values stored in a single array

$ ARRAY1 =阵列(1,2,3,4,5);

$ ARRAY1 =阵列(1,2,3);

我希望能够呼应(或的print_r )包含数组屏幕内的值,仅由逗号和空格分隔。

I want to be able to echo (or print_r) the values contained within an array to screen and separated only by commas and spacing.

例如:

在观念是有回声 $数组1 来显示:

the 'idea' is to have echo $array1 to display:

1,2,3

从上面的第二示例。

推荐答案

<一个href=\"http://us.php.net/manual/en/function.implode.php\">http://us.php.net/manual/en/function.implode.php

echo implode(", ", $array);

这篇关于如何逗号分隔显示数组的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆