Home > Article > Backend Development > How to remove 0 from php 01
php 01 Method to remove 0: 1. Use the "intval($sn);" method to remove the 0 in front of the string; 2. Use the "ltrim($sn,"0");" method to remove characters The 0 in front of the string.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
How to remove 0 from php 01?
Remove leading zeros
intval() gets the integer value of the variable.
ltrim() function removes whitespace characters or other predefined characters on the left side of a string.
$sn = 01; $id1 = intval($sn); //方法一 1 $id2 = ltrim($sn,"0"); //方法二 1
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to remove 0 from php 01. For more information, please follow other related articles on the PHP Chinese website!