I have 2 arrays:
- $DatesToDelete()
- $ArrayAllDates()
$DatesToDelete() contains a list of dates, like this:
01/11/2022
02/11/2022
03/11/2022
04/11/2022
05/11/2022
06/11/2022
07/11/2022
08/11/2022
09/11/2022
10/11/2022
11/11/2022
12/11/2022
13/11/2022
14/11/2022
15/11/2022
16/11/2022
17/11/2022
18/11/2022
19/11/2022
20/11/2022
21/11/2022
22/11/2022
23/11/2022
24/11/2022
25/11/2022
26/11/2022
27/11/2022
28/11/2022
29/11/2022
30/11/2022
$ArrayAllDates() contains another list of dates, like this:
07/11/2022
07/11/2022
18/11/2022
17/11/2022
02/12/2022
**My goal is to find if dates coming from $DatesToDelete() are contained in $ArrayAllDates()
**
I’m not a PHP expert and I tried a lot of loops with foreach() without success 🙁
Thank you
foreach($ArrayAllDates as $d) {
foreach($DatesToDelete as $e) {
if(in_array($b,$arrayalldates)){
}
}
}
2
Answers
you can use this looping
if you want save this contain date to array
As @DCodeMania said, you can use the array_intersect function (https://www.php.net/manual/en/function.array-intersect.php).
For example: