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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -