in loop how add string by comma in php

Solutions on MaxInterview for in loop how add string by comma in php by the best coders in the world

showing results for - "in loop how add string by comma in php"
Bart
30 Nov 2020
1//join string values by comma in loop
2$string = '';
3
4foreach ($array as $key => $value) {
5    $string .= ",$value";
6}
7
8$string = substr($string, 1); // remove leading ","
9//@sujay
Jaxson
08 Jul 2018
1$values = "";
2
3foreach ($stuffs as $stuff) {
4    $values != "" && $values .= ",";
5    $values .= $stuff;
6 }
7
8echo $values;
9//@sujay