Use sprintf
:
sprintf('%08d', 1234567);
Alternatively you can also use str_pad
:
str_pad($value, 8, '0', STR_PAD_LEFT);
More Related Contents:
- Convert number into xx.xx million format? [closed]
- php , I want to build array from 12 values each value has max number of 2048
- Convert one date format into another in PHP
- Show a number to two decimal places
- Why does PHP consider 0 to be equal to a string?
- How to mathematically evaluate a string like “2-1” to produce “1”?
- Is there an easy way to convert a number to a word in PHP?
- Why is PHP printing my number in scientific notation, when I specified it as .000021?
- Display numbers with ordinal suffix in PHP
- Test if number is odd or even
- Converting words to numbers in PHP
- Remove useless zero digits from decimals in PHP
- Automatic image format detection in PHP
- What is the best way to validate a credit card in PHP?
- Strange behaviour with numbers that have a leading zero [duplicate]
- PHP: Express Number in Words [duplicate]
- Round to max thousand, hundred etc in PHP
- python format datetime with “st”, “nd”, “rd”, “th” (english ordinal suffix) like PHP’s “S”
- PHP “pretty print” HTML (not Tidy)
- PHP: Create an array for a range
- PHP prepend leading zero before single digit number, on-the-fly [duplicate]
- Max file number can php upload at same time
- Convert to date format dd/mm/yyyy
- Format date from database?
- php random x digit number
- PHP remove commas from numeric strings
- Laravel Carbon Data Missing
- Youtube I.D parsing for new URL formats
- Converting to date in PHP from yyyymmdd format
- Convert Time String to Decimal Hours PHP [closed]