Re: for() problem on php-4.0.6
| From: | Pavel Jartsev | Date: | Mon, 09 Jul 2001 09:27:28 +0000 |
| Subject: | Re: for() problem on php-4.0.6 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56906@lists.php.net to get a copy of this message | ||
Mesut Tunga wrote:
>
> Hi All,
>
> a for statment like below has been worked lowe php versions:
>
> for ( $idx = "01"; $idx <= 12; $idx++ )
> {
> echo " <option value=\"$idx\">$idx\n";
> }
>
> like 01, 02, 03, 04, ... 12
>
> but same statment on 4.0.6 version, it writes
>
> 01, 2, 3, 4, ... 12
>
> what is the different between verisons? or how can I solve this?
>
Try this:
<?
for ( $idx = 1; $idx <= 12; $idx++ )
{
printf( " <option value=\"%02d\">\n",$idx );
}
?>
See also:
http://www.php.net/manual/en/function.printf.php
http://www.php.net/manual/en/function.sprintf.php
--
Pavel a.k.a. Papi