I wouldn't really use a while statement for this, but a for loop instead, as it
needs less code:
";
for($i =1;$i<=12;$i++)
{
$dateformat = date("M", mktime(0,0,0, $i,0,0));
echo <<$dateformat $i
HTML;
}
echo "";
?>
The other code was starting from 0 and going to 12, which is 13 mo
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:
>
>
> echo "";
> $i ="0";
> while($i <="12") {
>
> $dat
This is because of your mktime() call. You're trying to get the zeroth day of
the month, which is the last day of the preceding month. Using mktime(0, 0, 0,
$i, 1) instead should give you the desired results, assuming you do start at 1,
and not 0 as you have in your code.
---
Simon Welsh
On 17/
3 matches
Mail list logo