Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个类似的循环:
$names = " [$name , $surname] "; echo "$names";
结果:
[Mario,Rossi] [Aberto,rossi] [Giovanni,Rossi]
我会这个输出:
[Mario,Rossi], [Aberto,rossi], [Giovanni,Rossi]
没有 , 在最后一个结果中 * 我不知道循环中的结果数
$names[] = " [$name , $surname] "; $comma_sep = implode(",", $names); echo "<pre>{$comma_sep}</pre>";
<pre>如果您想使用这样的换行符,则应使用标签预先格式化数据。
<pre>
使用简单的数组内爆将在这里解决问题:
$names[] = "[$name, $surname]"; echo implode(",\n", $names);