<?php 
include("dbConfig.php");
$dates_t = array();
$date_from = "2023-08-23";
$date_to = "2023-08-30";
$begin = new DateTime($date_from);
          $end = new DateTime($date_to);
          $end->modify('+1 day');
          $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end);
             foreach($daterange as $date){
                array_push($dates_t,$date->format("Y-m-d"));                                           
                 }
               print_r($dates_t)."</br>";  



               //
               $taked_dates = array();
                $sql_taked="SELECT * FROM hr_takeed_hodor_ensraf_tbl where employ_id='271562'";
                     $result_taked = $conn->query($sql_taked);
                    if ($result_taked->num_rows > 0) {
                                  while($row_taked = $result_taked->fetch_assoc()) {
                                    $begin = new DateTime($row_taked["date_from"]);
                                    $end = new DateTime($row_taked["date_to"]);
                                    $end->modify('+1 day');
                                    $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end);
                                     foreach($daterange as $date){
                                         //echo $date->format("Y-m-d") . "<br>";
                                    array_push($taked_dates,$date->format("Y-m-d"));
                                                             
                                     }
                                                        
                                  }}
                                  print_r($taked_dates)."</br>";

                                  $commonElements = array_intersect($dates_t, $taked_dates);
                                $count = count($commonElements);
                                echo "Count of common elements: " . $count;
?>