Home > Backend Development > PHP Tutorial > Recommended 10 commonly used ways to automatically add 0 on the left side, welcome to download!

Recommended 10 commonly used ways to automatically add 0 on the left side, welcome to download!

巴扎黑
Release: 2023-03-09 16:10:01
Original
1600 people have browsed it

Copy code The code is as follows: This time it will appear: 001 If you want to increase the number of digits, you can increase 1000, and then increase 3 as well. Example: If I want to add "4 zeros", line 03 will look like this. Copy the code. The code is as follows: Actually, to show how many digits there are in total, just add as many 0s after $sourceNumber+1, and the last number will be directly changed to how many digits are displayed. Better method: string str_pad ( string $input, int $pad_length [, string $pad_string [, int $pad_type]] ) Copy code code

1. phison-up10 mass production Tool v1.78.00 PHP Number left side automatically adds 0

Introduction: phison-up10 mass production tool v1.78.00: Phison-up10 mass production tool v1.78.00 PHP number left Automatically add 0 on the side: Copy the code as follows: At this time It will appear: 001 If you want to increase the number of digits, you can increase 1000

2. PHP Automatically fill in 0 on the left side of the number_PHP tutorial

Introduction: PHP automatically adds 0 to the left side of numbers. Copy the code as follows: ?php $sourceNumber="1"; $newNumber=substr(strval($sourceNumber+1000),1,3); echo "$newNumber"; ? At this time: 001 will appear if you want to add bits If you want to count, you can

3. PHP automatically adds 0 to the left of the number

Introduction: PHP automatically adds 0 to the left of the number 0. Copy the code as follows: ?php $sourceNumber="1"; $newNumber=substr(strval($sourceNumber+1000),1,3); echo "$newNumber"; ? At this time: 001 will appear if you want to add bits If you want to count, you can

4. PHP automatically adds 0 to the left of several numbers

Recommended 10 commonly used ways to automatically add 0 on the left side, welcome to download!

##Introduction: PHP automatically fills 0 on the left side of several numbers

5. PHP Automatically fills 0 on the left side of numbers_php tips

Introduction: For example: employee’s job number X001 Although MySQL's own fields are set to the zerofill attribute, the missing digits will be filled with 0, but this function can only be used on numeric fields. So I have to rely on PHP when necessary.

【Related Q&A recommendations】:

The above is the detailed content of Recommended 10 commonly used ways to automatically add 0 on the left side, welcome to download!. For more information, please follow other related articles on the PHP Chinese website!

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