I'm trying to create arrays with days of the week. "Apparently" seems to work:
$array_dia_da_semana = array("DOMINGO","SEGUNDA","TERÇA","QUARTA","QUINTA","SEXTA","SÁBADO");
$array_dia_da_semana_d = [];
$array_dia_da_semana_s = [];
$array_dia = [];
$data = new DateTime('2017-08-14'); // Pega a data de hoje
for ($a=1; $a <=7; $a++)
{
$array_dia[$a - 1] = $data;
echo(date_format($array_dia[$a - 1],"Y-m-d") . " iiii<br>");
$diaN = date( "w", strtotime($data->format('Y-m-d')));
echo("dia em numero.. " . $diaN) . "<br> ";
$data->modify('+1 day');
$array_dia_da_semana_s[] = $array_dia_da_semana[$diaN];
echo($array_dia_da_semana_s[$a-1] . "<br>");
$array_dia_da_semana_d[] = $diaN;
echo($array_dia_da_semana_d[$a-1] . "<br>");
}
All echos
shows me correctly what I want to see. However, if below this is to do another for:
for ($a=0; $a <=6; $a++)
{
echo(date_format($array_dia[$a],"Y-m-d") . " <br>");
}
What I see is that all items in the array have same date . Which in this case is the last day manipulated "2017-08-21".
I really do not know why.