Removing last comma in a string – PHP
Last modified on by
Hi guys, Here I am gonna share how to remove the last comma in a string by using php rtrim function.
The rtrim() function will remove whitespaces or other predefined character from the right side of a string.
$text_with_comma = “1,2,3,4,5,6,7,”;
$removed = rtrim($text_with_comma, ‘,’);