Re: odd while behavior...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 16, 2010 at 11:12:03AM -0400, Jason Pruim wrote:
> Okay so I'm just playing around with some stuff trying to learn more
> and expand my knowledge and I ran into something I don't
> understand... Take the following code:
> 
> <?PHP
> 
> echo "<select>";
> $i ="0";
>     while($i <="12") {
> 
>     $dateformat = date("M", mktime(0,0,0, $i,0,0));
>     $month = mktime(0,0,0, $i,0,0);
>     //echo date("M", mktime(0,0,0, $i,0,0));
>     //echo "<br>inside while<br>";
>     echo <<<HTML
>     <option value="{$i}">{$dateformat} {$i}</option>
> HTML;
>     $i++;
>     }
> echo "</select>";
> 
> ?>
> 
> which does display a select drop down box with the month's in it...
> But on my test server it starts the display at december... With
> setting $i = "1" i would have thought it should start at january?
> 
> Any ideas on what I missed? :)
> 
> 
> Thanks for looking! :)
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

You'r specifying day 0. Which actually is in december. It is an optional
argument. So you can specifify mktime(0,0,0,$1) instead.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux