Is there a quick way ( existing method) Concatenate array element into string with ',' as the separator? Specifically I am looking for a single line of method replacing the following routine:
//given ('a','b','c'), it will return 'a,b,c'
private static function ConstructArrayConcantenate($groupViewID)
{
    $groupIDStr='';
    foreach ($groupViewID as $key=>$value) {
        $groupIDStr=$groupIDStr.$value;
        if($key!=count($groupViewID)-1)
            $groupIDStr=$groupIDStr.',';
    }       
    return $groupIDStr;
}
                This is exactly what the PHP implode() function is for.
Try
$groupIDStr = implode(',', $groupViewID);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With