trim comma in php code example Example 1: remove last comma from string php rtrim($my_string, ','); Example 2: trim comma from variable in php rtrim($my_string,',');