PHP calendar and weekday output

I took this calendar.


And I made 2 inputs with a date range selection. I have a code that makes this range

$d1 = date('d.m', strtotime($_POST["date1"]));
$d2 = date('d.m', strtotime($_POST["date2"]));
$dates = range($d1,$d2);

Now I want it to output what day of the week it is.

Answer 1, authority 100%

$dayweek  = array(
"0"=>"" ,
"1"=>"" , 
"2"=>"" ,
"3"=>"" ,
"4"=>"" ,
"5"=>"" , 
"6"=>"" );
echo( $dayweek[date("w", strtotime($_POST["date1"]))]);


But you need to write the locale there, something like

setlocale ( LC_TIME , 'Russian_Russia.1251' );

Answer 2, authority 100%

In your version, it will work if you add below:

$wdRu = Array('','','','','','','');
for ($i=0;$i<sizeof($dates);$i++) {
  $weekDay[$i] = date('w',strtotime(str_replace(',','.',$dates[$i]).'.11'));
  $out .= $wdRu[$weekDay[$i]].' '.$dates[$i].' ';

With this approach, you can use the construction


to display the Russian name of the day of the week, in your loop, where you need it, because it will have an iterator equal to the iterator in $dates

PS: By the way, your approach will only work for this year. $dates contains the numbers 24.09; 25.09 etc.

PPS: see this topic PHP date array