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  TypeScript code snippet - How to search for imports in vsExample?

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.