Solved

2 digits

Posted on 2009-05-06
2
203 Views
Last Modified: 2012-05-06
hello there,
i am doing a for($i) and displaying the data but its showing it like 1,2,3,4
is it possible to show it like this 01,02,03?
<? for($i=1;$i<=10;$i++) { ?>

Open in new window

0
Comment
Question by:XK8ER
2 Comments
 

Expert Comment

by:MunichJoe2009
Comment Utility
This may solve your problem:

http://www.htmlite.com/php011.phphttp://www.htmlite.com/php011.php

(see middle of the page)

Regards,
MunichJoe2009

0
 
LVL 16

Accepted Solution

by:
Chris Harte earned 500 total points
Comment Utility
Depends on how you are trying to display $i.
Using printf() instead of echo allows you to add a leading zero


for ($i = 1; $i <= 10; $i++)

{

     printf("%02d", $i);

}

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now