Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

2 digits

Posted on 2009-05-06
2
Medium Priority
?
210 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

660 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