Find the last element of an array while using a foreach loop in PHP
Note: This doesn't work because calling next() advances the array pointer, so you're skipping every other element in the loop
why so complicated?
foreach($input as $key => $value) { $ret .= "$value"; if (next($input)==true) $ret .= ",";}
This will add a , behind every value except the last one!