This while() make me nuts
<p>I know that this problem is really pitty and i just made a really big mistake what i cannot realise. I want to load an array with dates. I have the starting and the ending dates. Here is my code:</p>

<pre><code>$year_from=2011;
$month_from=1;
$year_till=2012;
$month_till=5;
$array=array();
$year=$year_from;
$month=$month_till;
while($year!=$year_till and $month!=$month_till){
    $array[]=$year.'-'.$month;
    if($month==12){
        $month=1;
        $year=$year+1;
    }else{
        $month=$month+1;
    }
}
print_r($array);
</code></pre>

<p>This script's out put will be the following:</p>

<pre><code>Array ( [0] =&gt; 2011-1 [1] =&gt; 2011-2 [2] =&gt; 2011-3 [3] =&gt; 2011-4 [4] =&gt; 2011-5 [5] =&gt; 2011-6 [6] =&gt; 2011-7 [7] =&gt; 2011-8 [8] =&gt; 2011-9 [9] =&gt; 2011-10 )
</code></pre>

<p>Please help i know it is a really simple task but it's driving me crazy.
Any help is greatly appriciated.</p>

<p><strong>EDIT:</strong></p>

<p>Desired output:</p>

<pre><code>Array ( [0] =&gt; 2011-1 [1] =&gt; 2011-2 [2] =&gt; 2011-3 [3] =&gt; 2011-4 [4] =&gt; 2011-5 [5] =&gt; 2011-6 [6] =&gt; 2011-7 [7] =&gt; 2011-8 [8] =&gt; 2011-9 [9] =&gt; 2011-10 [10] =&gt; 2011-11 [11] =&gt; 2011-12 [12] =&gt; 2012-1 [13] =&gt; 2012-2 [14] =&gt; 2012-3 [15] =&gt; 2012-4 )
</code></pre>
