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

后端 未结 10 1535
难免孤独
难免孤独 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:27

    I had a pesky "invisible" space at the end of my string and had to do this

     $update_sql=rtrim(trim($update_sql),',');
    

    But a solution above is better

     $update_sql=rtrim($update_sql,', ');
    

提交回复
热议问题