trim last character only if is comma php code example
Example 1: remove last comma from string php
rtrim($my_string, ',');
Example 2: php remove last character from string if comma
$string = rtrim($string, ',');
rtrim($my_string, ',');
$string = rtrim($string, ',');