1
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 the echos
correctly show me what I want to see. However, if just below that is another do:
for ($a=0; $a <=6; $a++)
{
echo(date_format($array_dia[$a],"Y-m-d") . " <br>");
}
What I see is that all the items in the array are with the same date. That in this case is the last day manipulated "2017-08-21".
I really don’t know the reason for this behavior.
The code goal is to create a calendar?
– rray
Good afternoon.. I am doing a time screen. With the arrays mounted each ABA will have a select with the DIA of the $array_dia variable-array. So when I mount the first tab I pass the $array_dia[0] parameter that would have to contain the day 2017-08-14 the second tab step the $array_dia[1] parameter that would have to contain the day 2017-08-15 and so on :)
– Ricardo M.Souza