如何在数组项转换为PHP逗号分隔字符串? [英] How to convert items in array to a comma separated string in PHP?
本文介绍了如何在数组项转换为PHP逗号分隔字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/2435216/how-to-create-comma-separated-list-from-array-in-php\">How从阵列中的PHP创建逗号分开?
块引用>由于此阵:
$标签=阵列('TAG1','标签2','TAG3','TAG4','...');
我如何生成此字符串(使用PHP):
$标签='TAG1,TAG2,TAG3,TAG4,......;
解决方案使用破灭:
$标签=破灭('',阵列('TAG1','标签2','TAG3','TAG4'));
Possible Duplicate:
How to create comma separated list from array in PHP?Given this array:
$tags = array('tag1','tag2','tag3','tag4','...');
How do I generate this string (using PHP):
$tags = 'tag1, tag2, tag3, tag4, ...';
解决方案Use implode:
$tags = implode(', ', array('tag1','tag2','tag3','tag4'));
这篇关于如何在数组项转换为PHP逗号分隔字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文