php - Add elements to a dynamic array with array_push -


i have array file_months changes when new month adds folder:

array (     [0] => 01     [1] => 02     [2] => 03 ) 

what want display months in select option, tried :

$nbr_mois = array('0'=>'01','1'=>'02','2'=>'03','3'=>'04','4'=>'05','5'=>'06','6'=>'07','7'=>'08','8'=>'09','9'=>'10','10'=>'11','11'=>'12'); foreach ($nbr_mois $key => $value) {     if($value!=$file_months) array_push($file_months,$value); } 

but doesn't add missing months, adds them all! :

array (     [0] => 01     [1] => 02     [2] => 03     [3] => 01     [4] => 02     [5] => 03     [6] => 04     [7] => 05     [8] => 06     [9] => 07     [10] => 08     [11] => 09     [12] => 10     [13] => 11     [14] => 12 ) 

i think array_merge work without loop.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -