3
I have a routine that generates a list of years dynamically from an initial year defined in the array which in this case is the year 2015 to the current year.
See the array structure:
$rray = array(
"1" => "2015" #Ano inicial
);
Routine that generates the list of years:
<?php
$rray = array(
"1" => "2015"
);
$ano = $rray[1];
$i = 1;
while ($ano <= date("Y")) {
$rray[$i] = $ano;
$ano++;
$i++;
}
print_r($rray);
The above routine generates the following output array:
Array
(
[1] => 2015
[2] => 2016
[3] => 2017
)
However I would like the indexes that are numerical [1] [2] [3]
were the same year.
Instead of being
Array
(
[1] => 2015
[2] => 2016
[3] => 2017
)
I wish it were
Array
(
[2015] => 2015
[2016] => 2016
[2017] => 2017
)
How could I do that?