Tag Archives: remove last character in a string

How to remove the last character in a string in PHP ?

snippets

How to remove the last character in a string in PHP ? You have a string, let’s say “1,2,3,4,5,6,7,8,” that is generated in a loop, and you want to remove the last comma that is occurred on the last position of the string, to obtain a string like this: “1,2,3,4,5,6,7,8”. 1st solution

2nd

Request an article ←