PHP simple : PHP tutorial, MySQL tutorial
PHP Tutorial - Free PHP Script

Home | Tutorials | Php vs Node.Js | Web Tools

Make a Number Format

Tutorials > Make a Number Format

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 for your counter, category or product ID. etc.


Source Code
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
$num = 1;

// Output number in $num with 3 digits with "0" added.
printf("%03d", $num);

<hr />
// Make number 5 to 15 with for loop.

// Output number in $num with 4 digits with "0" added.
printf("%04d", $num);
echo "<br/>";


Copy this code and save as number_format.php to your root folder, open this file by browse to http://localhost/number_format.php.

Put Ebay RSS Feeds onto your website
SEO Elite Software
Domain Dashboard CPanel & Seo Manager
Work at Home Ideas and Opportunities
Introduction & Get Start
Using Form
PHP Tags
PHP Variables
PHP Control Structures
Create Database & Table
Database Connection
Insert Record
Select Record
Update Record
Delete Record
[email protected]