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 up to the current year.
View array structure:
$rray = array(
"1" => "2015" #Ano inicial
);
Routine that generates 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
)
But I would like indexes that are numeric [1] [2] [3]
to be the year itself.
Instead of being
Array
(
[1] => 2015
[2] => 2016
[3] => 2017
)
I would like it to be
Array
(
[2015] => 2015
[2016] => 2016
[2017] => 2017
)
In what way could I do this?