Erase part of string in php if same character until the end -
Suppose I have a string as the following:
11221211111212111111211111222222222
and what I want to get:
11221211111212111111211111
Actually, I have been wiped from the last '2 In the "first one" last , if it has any meaning, I have considered running the string with foreclosure, but I would like to check out a code-friendly option. Through performance and readability ...
$ string = "11221211111212111111211111222222222"; $ NewString = rtrim ($ string, substr ($ string, -1)); Echo $ newString;
Comments
Post a Comment