Skip to content

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
See also  Python code snippet - How to import somthing from another directory in pyhon?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.