how to add comma in loop in each value php code example
Example 1: in loop how add string by comma in php
//join string values by comma in loop
$string = '';
foreach ($array as $key => $value) {
$string .= ",$value";
}
$string = substr($string, 1); // remove leading ","
//@sujay
Example 2: in loop how add string by comma in php
$values = "";
foreach ($stuffs as $stuff) {
$values != "" && $values .= ",";
$values .= $stuff;
}
echo $values;
//@sujay