How do you format and output a number with leading zero's?
Answers were Sorted based on User's Feedback
Answer / mahesh
$d=450;
$d = str_pad($d,6,0,0);
echo $d;
OUT PUT
000450
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / pradeep
Using sprinf("%04d",$num);
The above function will return a number of length 4.
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / mahidhar
syntax:number_format("number","decimal places","string
seperator","string thousands seperator");
Example:number_format('1000',2,'.','')
| Is This Answer Correct ? | 6 Yes | 6 No |
What does $_env means?
How to redirect https to http url and vice versa in .htaccess?
What is the use of friend function in php?
What is the substitution of submit in PHP?
What is default session time and path in PHP. How to change it?
What is the main difference between require() and include()?
How many ways there are to fetch the data from the Database?
Does php class need constructor?
How can we create a database using PHP and mysql?
How to check a key exist in an array?
What is overloading and overriding in php?
What is session_start () in php?