Php how to remove any last commas
rtrim for example:
$str = 'foo,bar,blah,bleh,';
echo rtrim($str,',');
// foo,bar,blah,bleh
rtrim('test,,,,,', ',');
See the manual.
completely different way:
$str = "1,2,3,4,";
$str = substr($str,0,strlen($str)-1);