You can try this -
$date = "1 June 2015"; // The initial date
$fileNum = array(5, 2, 3); // The number of files to be considered
$total = array_sum($fileNum); // Total number of files
$array = array(); // Array to be filled
$j = 1; // The number for increment
foreach($fileNum as $num) {
$i = 1; // The number to compare the file numbers
while($i <= $num) {
$array['test' . $j . '.txt'] = $date; // Store the values
$j++;
$i++;
}
$date = date('j F Y', strtotime('+ 1 DAY', strtotime($date))); // Increment the date
}
var_dump($array);
Output
array(10) {
["test1.txt"]=>
string(11) "1 June 2015"
["test2.txt"]=>
string(11) "1 June 2015"
["test3.txt"]=>
string(11) "1 June 2015"
["test4.txt"]=>
string(11) "1 June 2015"
["test5.txt"]=>
string(11) "1 June 2015"
["test6.txt"]=>
string(11) "2 June 2015"
["test7.txt"]=>
string(11) "2 June 2015"
["test8.txt"]=>
string(11) "3 June 2015"
["test9.txt"]=>
string(11) "3 June 2015"
["test10.txt"]=>
string(11) "3 June 2015"
}
Update
$fileNum = array(5 => "1 June 2015", 2 => "2 June 2015", 3 => "3 June 2015"); // Set the array with file number and corresponding dates
$total = array_sum($fileNum);
$array = array();
$j = 1;
foreach($fileNum as $num => $date) {
$i = 1;
while($i <= $num) {
$array['test' . $j . '.txt'] = $date;
$j++;
$i++;
}
}
$date = $test['test'.$n.'.txt']where$n = filenumber