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

Is php faster than javascript?

0 Answers  


Explain how does one prevent the following warning ‘warning: cannot modify header information – headers already sent' and why does it occur in the first place?

0 Answers  


What is the latest version of php?

0 Answers  


Which function is used in php to check the data type of any variable?

0 Answers  


How to genrate report in wordpress cms

0 Answers  






How do you end a function in python?

0 Answers  


What's php?

0 Answers  


How does cookies work in php?

0 Answers  


Where are the persistent cookies stored on your computer?

0 Answers  


Explain about Type Juggling in PHP?

2 Answers  


Write down the code for save an uploaded file using php?

0 Answers  


How failures in execution are handled with include() and require() functions?

0 Answers  


Categories