开发者

PHP, Echoing an array into a string of comma seperated values

I have a multi select box i am using to allow users to select multpile users, this is fine but the $_POST output is an array.

How would i get these values to be formatted like so

100,200,300,4开发者_如何学C00

So i need to echo out the values, add a comma, but dont add the comma for the last value

Any help would be grand.

Cheers


You could use implode:

return implode(',', $_POST['users']);


$array = array(100, 200, 300, 400); // Or get from your $_POST value or what have you

echo implode(',', $array); // "100,200,300,400"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜