how do i remove a comma off the end of a string?

后端 未结 10 1530
难免孤独
难免孤独 2020-11-27 14:15

I want to remove the comma off the end of a string. As it is now i am using

$string = substr($string,0,-1);

but that only removes the last

10条回答
  •  时光说笑
    2020-11-27 14:43

    have a look at the rtrim function

    rtrim ($string , ",");
    

    the above line will remove a char if the last char is a comma

提交回复
热议问题