ciao a tutti... sto cercado un modo di riordinare automaticamente i mesi in una select.

il criterio e' far partire la dropdown dal mese in cui mi trovo e poi aggiungere gli altri 11... nel caso di oggi, l'ordine sara' Nov, Dec, Gen, Feb, Mar, Apr, Mag, Giu, Lug, Ago, Sep, Ott

il mio codice e' questo, ma per ora non fa che elencare i mesi nell'ordine convenzionale, per due volte.

qualche suggerimento?

Codice PHP:

<select name="depmonth" onChange="MM_callJS('month()')">
                <?
$thismonth 
date('n');
                
$montharray = array (
                
"1" => "Jan",
                
"2" => "Feb",
                
"3" => "Mar",
                
"4" => "Apr",
                
"5" => "May",
                
"6" => "Jun",
                
"7" => "Jul",
                
"8" => "Aug",
                
"9" => "Sep",
                
"10" => "Oct",
                
"11" => "Nov",
                
"12" => "Dec"
                
);
                
//reorder the array
                
$position array_search($thismonth$montharray); //position of the actual month in the array
                
$firstpart array_slice($montharray$position); //cut away the array and return from the actual month to dec.
                
$position =  $position - ($position 2); //make it negative
                
$lastpart array_slice($montharray$position); //get the last part
                
$montharray array_merge($firstpart$lastpart); //reorder montharray                
                
foreach ($montharray as $k => $v) { //print the month
                       
echo "<option value=\"$k\">$v</option>\n";
                }                
                
?>
                </select>