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

Which function you can use in php to open a file for reading or writing or for both?

0 Answers  


Tell me how to strip whitespace (or other characters) from the beginning and end of a string?

0 Answers  


How to swap two variables without using 3rd temp variable.

0 Answers  


How to count a number of words in a string in php?

0 Answers  


how can i disable multiple user in the same password in my website using any scripts

1 Answers  


How to create database connection and query in php?

0 Answers  


How do I run a php script in windows?

0 Answers  


What is difference between php and wordpress?

0 Answers  


how many types of inheritance is there in php? name there?

10 Answers  


How do you end a function in python?

0 Answers  


how can refresh current page automatically, without press any button and anchor tag.

5 Answers  


What type of headers that PHP supports?

0 Answers  


Categories