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:
$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);
This script's out put will be the following:
Array ( [0] => 2011-1 [1] => 2011-2 [2] => 2011-3 [3] => 2011-4 [4] => 2011-5 [5] => 2011-6 [6] => 2011-7 [7] => 2011-8 [8] => 2011-9 [9] => 2011-10 )
Please help i know it is a really simple task but it's driving me crazy. Any help is greatly appriciated.
EDIT:
Desired output:
Array ( [0] => 2011-1 [1] => 2011-2 [2] => 2011-3 [3] => 2011-4 [4] => 2011-5 [5] => 2011-6 [6] => 2011-7 [7] => 2011-8 [8] => 2011-9 [9] => 2011-10 [10] => 2011-11 [11] => 2011-12 [12] => 2012-1 [13] => 2012-2 [14] => 2012-3 [15] => 2012-4 )