i have two date :
$from = 2022-11-01
$to = 2022-11-05
now , i wanna create a array like this :
$date = [‘2022-11-01′,’2022-11-02′,’2022-11-03′,’2022-11-04′,’2022-11-05’]
and now check ‘2022-11-03’ is exist in $date array or not.
alrady use :
$date = Carbon\CarbonPeriod::create($from, $to);
if(in_array('2022-11-03', $date)){
echo "Got it";
}
#But Still not Work
>Solution :
You can just check if the CarbonPeriod contains the date you check:
$from = '2022-11-01';
$to = '2022-11-05';
$date = Carbon\CarbonPeriod::create($from, $to);
if ($date->contains('2022-11-03')) {
echo 'Got it';
}