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.

number_format.php

Source Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?
$num = 1;

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

<hr />
<?
// Make number 5 to 15 with for loop.
for($num=5;$num<=15;$num++){

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

</body>
</html>

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

Advertise
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
PHP Tags
PHP Variables
PHP Control Structures
MySQL
Create Database & Table
Database Connection
Insert Record
Select Record
Update Record
Delete Record

PHPsimple.net
[email protected]