How do I remove the last comma from a string using PHP?
Use the rtrim
function:
rtrim($my_string, ',');
The Second parameter indicates the character to be deleted.
Try:
$string = "'name', 'name2', 'name3',";
$string = rtrim($string,',');
Use the rtrim
function:
rtrim($my_string, ',');
The Second parameter indicates the character to be deleted.
Try:
$string = "'name', 'name2', 'name3',";
$string = rtrim($string,',');