如果有这个数组:
$a = array("one", "two", "three");
我想将其转换为此字符串:
$s = "one, two, three";
E.g:
$s = paste($a, sep=", ");
答案 0 :(得分:3)
使用implode:
$s = implode(', ',$a);
答案 1 :(得分:0)
$a = array("one", "two", "three");
foreach($a as $value) {
$string = $string . ($value != '' ? '' : ', ') . $value;
}