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 the identity operator === compare two values?

0 Answers  


Which variable declarations within a class is invalid in php?

0 Answers  


Which is better php praogramming or cad/cam scope wise and also salaray wise?

0 Answers  


How to set a page as a home page in a php based site?

0 Answers  


what is interface in php? how it is use?

10 Answers   Infosys, PHP, Times, Torque Infotech, Wipro,






Tell me what is the importance of "action" attribute in a html form?

0 Answers  


What is == and === in php?

0 Answers  


What is the difference between php and core php?

0 Answers  


How to pass variables and data from php to javascript?

0 Answers  


What is composer install?

0 Answers  


How can we convert asp pages to PHP pages?

3 Answers   Agile Software,


Do you know what is the use of rand() in php?

0 Answers  


Categories