Filling array with different, but same-range data in PHP

0

I have the following code that is working perfectly, but I need the results inside the $arrayDiasSemestre to be '1' for the monday, '2' for the tuesday and so on ...

$inicio = new DateTime($start_date);
$fim = new DateTime($end_date);
$fim->modify('+1 day');

$interval = new DateInterval('P1D');
$periodo = new DatePeriod($inicio, $interval ,$fim);

foreach($periodo as $data){
    $arrayDiasSemestre[] = $data->format("l");
}   

How could I change this input at the time of filling the array ? Would anyone know of any way to do this?

    
asked by anonymous 29.11.2014 / 17:31

1 answer

2

If I understand your question well, you only need to use w which is the day of the week (numeric), instead of l which is the name of the day of the week.

foreach($periodo as $data){
    $arrayDiasSemestre[] = $data->format("w");
}

Example: link

    
29.11.2014 / 17:57