$holder = \'\';
foreach($fields as $key){
$holder .= $key.\', \';
}
echo $holder;
I have the code above, it outputs \"a, b, c, \" I want to r
You can use implode()
to join all array elements together :
<?php
$holder = implode(', ', $fields);
echo $holder;
?>
You can use substr like this
$holder = '';
foreach($fields as $key){
$holder .= $key.', ';
}
$newholder=substr($holder, 0, -1);
echo $newholder;
That's not how it's done.
$holder = join(', ', $fields)