How do you format and output a number with leading zero's?

Answers were Sorted based on User's Feedback



How do you format and output a number with leading zero's?..

Answer / mahesh

$d=450;
$d = str_pad($d,6,0,0);
echo $d;
OUT PUT
000450

Is This Answer Correct ?    8 Yes 0 No

How do you format and output a number with leading zero's?..

Answer / pradeep

Using sprinf("%04d",$num);

The above function will return a number of length 4.

Is This Answer Correct ?    6 Yes 1 No

How do you format and output a number with leading zero's?..

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

Post New Answer

More PHP Interview Questions

What is mysqli_fetch_array?

0 Answers  


How can we enable error reporting in php?

0 Answers  


How can image properties be retrieved in php?

0 Answers  


Does apache use php?

0 Answers  


Why is used in php?

0 Answers  


"$this" what type of object it is?

2 Answers  


when ever the user logged in the database table the current registered date will be appeared

3 Answers  


In PHP how many size data can upload by default?

9 Answers   Classic Infotech, PG Software,


How to link one site backend to another site frontend?

0 Answers   Global Logic,


Explain different sorting function in php?

0 Answers  


Is it possible to remove the html tags from data?

0 Answers  


What is PHP?

8 Answers  


Categories