right trim in php code example Example: php rtrim $colors=trim("blue,red,green,",",");//remove last , with rtrim