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

How does csrf attack work?

0 Answers  


What is cookies? How to create cookies in php?

0 Answers  


What is difference between variable declaration and variable definition?

0 Answers  


what is the difference between mysql_fetch_array() and mysql_fetch_row()?

17 Answers   Google,


Explain the visibility of the property or method?

0 Answers  






What is super () python?

0 Answers  


How many bootable file in O/S - XP,2000, and 98. which are the files.

1 Answers   IBM,


Who created numbers?

0 Answers  


What are the current versions of apache, PHP, and mysql?

21 Answers  


Is php 5.6 secure?

0 Answers  


Explain the advantages of using PHP?

0 Answers  


hi, i have knowledge about PHP/MYSQL,i am fresher of M.Sc-IT 2009 pass out,any recruitment in PHP please let me know.my email id:nathiyasms@gmail.com

0 Answers  


Categories