2
How do I delete the first number if it equals "0", for example, I have the following number "0123" would be "123", if it were "123" nothing would happen.
2
How do I delete the first number if it equals "0", for example, I have the following number "0123" would be "123", if it were "123" nothing would happen.
5
You can use the ltrim, by default it removes spaces at the beginning of the text. However, specifying the last argument, it will remove the specified characters if they appear at the beginning of the string:
ltrim ('0123', '0');
This will remove all 0 be submitted before.
Original: 00000123
ltrim: 123
Original: 101
ltrim: 101
Original: 014410
ltrim: 14410
Original: 100
ltrim: 100
Original: 00100
ltrim: 100
If the value is 0 it will also remove, ie 0, 00 or 00000 (...) will become emptiness, an alternative, if int is to use (int)ltrim ($numero, '0')
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
I used and solved my problem. Thank you!
– Smoke Rohden