Solved

2 digits

Posted on 2009-05-06
2
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:MunichJoe2009
ID: 24313873
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 17

Accepted Solution

by:
Chris Harte earned 500 total points
ID: 24313887
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

751 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