PHP: Echo Number with leading Zeros
Question by Guest | 2014-09-12 at 19:10
Is there any possibility to give numbers some leading zeros in PHP? Namely, that the number of places is always of equal length?
That means when considering the numbers 2 and 10, I would like to have made "002" and "010" out of them. The reason: I would like to output the numbers in a table and it is looking better when all values are written exactly under each other.
How is it possible to format numbers or digits in such a way using PHP? I think, the most difficult thing at this task is, that sometimes, you need only one zero and sometimes you need two zeros or even no zero at all to fill the string.
Tip | 2 Comments
Tip | 0 Comments
Question | 4 Answers
Question | 1 Answer
Article | 0 Comments
Tutorial | 0 Comments
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Ask your own question or write your own article on askingbox.com. That’s how it’s done.