How to Make Number Format like 001,002

Hello Guys Welcome to Coding Gurus Online Portal ...!

You must have noticed your account number is generated at random. It does not match with any of the normal series. The actual fact is the number generated has a series but when displayed it is given a format to make it of a particular lenght and type.

For such situtaions we use codes like the one below. This can be implemented in many cases like generating an ID number for registered users, generating account numbers, displaying docket/ticket numbers and many other activities.

For testing this code in this tutorial, we create 1 file

Code 1

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

Code 2


// Select your result and assign it to $result.

//Assign your Number Format to $format.

$output= $format . $result;
echo $output;