[php] How do I remove the last comma from a string using PHP?

Try:

$string = "'name', 'name2', 'name3',";
$string = rtrim($string,',');