Making number format like 0001, 0002

In this tutorial, we'll make number format like 0001, 0002, 0003 in stead of 1, 2 ,3. It's very easy to do this. Look at script, we use "printf" in stead of "echo" and ("%04d", $num) This mean show number in 4 digit. You can change number in any digits as you want by replce "4" in "%04d" with number of digit you want.


For testing this code in this tutorial, we create 1 file
1. number_format.php



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


// Result = 0001

Similar Post

PHP Script Image of the day

In this script shows you how to display image of the day. You can adapt this script to display quote of the day, knowledge of the day or something else you want. You don't have to change image everyday just change images once a week.

Simple Ad Rotation Script

This is a very easy and simple ad rotation script, you can set percentage to show the ads and you can adapt this script to rotate anything.