How to remove 0 from php 01

藏色散人
Release: 2023-03-10 15:22:02
Original
2108 people have browsed it

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
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template