Home  >  Article  >  Backend Development  >  How to remove 0 from php 01

How to remove 0 from php 01

藏色散人
藏色散人Original
2021-06-15 09:30:552118browse

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.

How to remove 0 from php 01

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn