Powrót do Dev Notes

php lista z pętli bez przecinka po ostatnim elemencie

$arr = array(1,2,3,4,5,6,7);
$copy = $arr;
foreach ($arr as $val) {
    echo $val;
    if (next($copy )) {
        echo ','; // Add comma for all elements instead of last
    }
}