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

Write logic to print Floyd's triangle in PHP?

0 Answers  


In How many ways can u represent Not equal?Give Syntax of all ways..

3 Answers  


Is php a backend?

0 Answers  


Which is the dependent variable?

0 Answers  


What is full form of PHP?

0 Answers  






How to send Email using PHP with MySQL in Linux Server?..

3 Answers  


can anyone explain about stored procedure,Triggers and transaction in php?

2 Answers  


What function do we use to find length of string, and length of array?

0 Answers  


Explain include(), include_once, require() and require_once?

0 Answers  


Which is the best method to fetch the data from mysql? 1.mysql_fetch_array() 2.mysql_fetch_object() 3.mysql_fetch_row() 4.mysql_fetch_assoc()

6 Answers  


What is the difference between indexed and associative array?

0 Answers  


What is singleton pattern in php?

0 Answers  


Categories