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 does the array operator '===' means?

0 Answers  


What does empty mean in php?

0 Answers  


Is polymorphism inherited?

0 Answers  


What is rtrim php?

0 Answers  


What is difference between session_unset and session_destroy?

0 Answers  


What type of inheritance that PHP supports?

15 Answers   Webwing Technologies,


how do we can copy of the content of a web page with the help og the URL and display them onto any other page

5 Answers  


What are the differences between PHP3 and PHP4 and PHP5? what is the current stable version of PHP?

0 Answers  


How to download and install php on windows?

0 Answers  


What are majic methords in php?

0 Answers  


What does sign mean php?

0 Answers  


What are the differences between PHP3 and PHP4 versions?

1 Answers  


Categories