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