How to remove leading 0 from php
This article mainly shows you "how to remove leading 0 from php". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to remove leading 0 from php".
Php method to remove the leading 0: 1, create a PHP sample file; 2, use the "ltrim ($str,'0');" method to remove the "0" on the left side of the string.
This article operating environment: windows7 system, PHP7.1 version, Dell G3 computer.
How does php get rid of leading 0?
It's very easy to get rid of the leading zero, as long as the ltrim function.
To remove leading 0, just use the following code:
$str = ltrim ($str,'0')
The ltrim () function removes white space characters or other predefined characters on the left side of the string.
Parameters:
String is required. Specifies the string to check.
Charlist is optional. Specifies which characters are removed from the string. If this parameter is omitted, all the following characters are removed:
"\ 0"-NULL
"\ t"-Tab character
"\ n"-Line break
"\ x0B"-Vertical Tab
"\ r"-enter
""-Spac
The above is all the contents of the article "how to get rid of leading 0 in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!