I want have two arrays
with date objects which I want to compare. The first array contains todays date and the next five days:
$today = date('Y-m-d');
$fiveDays = [];
for($i=0; $i <= 5; $i++){
$today = date('Y-m-d', strtotime('+1 day', strtotime($today)));
$fiveDays[] = date('Y-m-d', strtotime($today));
}
which gives the result:
0: "2018-09-14"
1: "2018-09-15"
2: "2018-09-16"
3: "2018-09-17"
4: "2018-09-18"
5: "2018-09-19"
the other array can contain multiple objects:
[{
days: (4) ["2018-09-13", "2018-09-14", "2018-09-15", "2018-09-16"]
duration: 4
end: "2018-09-16"
name: "vacation blabla"
start: "2018-09-13"
},
{
days: (5) ["2018-09-20", "2018-09-21", "2018-09-22", "2018-09-23", "2018-09-24"]
duration: 5
end: "2018-09-24"
name: "vacation blabla"
start: "2018-09-20"
}]
Now I want to check if one of the days/dates of the first array will or is in the vacations_array. How can I achieve that?
EDIT
When a match is found, the second array(with the vacation-periods) where the match is true, must be assigned to a $vacation
-array