How can I print number in 4 digit?

I want to print a list of numbers in php. But I want to print 4 digits of numbers (preceding with zero if necessary), e.g. 0001, 0009, 0076, 0129, 1234

What should I do?

Answers


printf("%04d", $num);

Need Your Help

Threads in Python 2.7

python multithreading global-variables

I'm new to Python. I tried to code the readers-writers problem with a stron reader priority, for some reason, python doesn't consider my global variable 'nor'. Is there an issue with the thread

The cons of a singleton pattern for user identification?

php session authentication singleton

I am building a model in Zend to build an object with key data, which will be lazyloaded as required and stored in a session variable.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.