Sort months array backwords from today
<p>I have the following array and need to sort it from current month backwards - All I get is NULL</p>

<p>Here's what i'm trying:</p>

<pre><code>$months = array(
'January' =&gt; 0,
'February' =&gt; 0,
'March' =&gt; 0,
'April' =&gt; 0,
'May' =&gt; 0,
'June' =&gt; 0,
'July ' =&gt; 0,
'August' =&gt; 0,
'September' =&gt; 0,
'October' =&gt; 0,
'November' =&gt; 0,
'December' =&gt; 0,
);

$current = date('F');
$start = array_search($current, $months);

$toshow = array();
$total = 0;
for($i = $start; $total &lt; 12; $i--)
{
if($i == 0)
{
    $i = 12;
}

$toshow[] = $months[$i];
$total++;
}

var_dump($toshow);
</code></pre>

<p>And the result I get is:</p>

<pre><code>array(12) { [0]=&gt; NULL [1]=&gt; NULL [2]=&gt; NULL [3]=&gt; NULL [4]=&gt; NULL [5]=&gt; NULL [6]=&gt; NULL [7]=&gt; NULL [8]=&gt; NULL [9]=&gt; NULL [10]=&gt; NULL [11]=&gt; NULL } 
</code></pre>
