Level 46
Loop through $satsatDates, turn from and to into Carbon instances, see if from is greater then and equal to $start and to is less than or equal to $finish and push them into an array.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I wonder if any of you encounter these problem.
// I have this array of date range for saturday to saturday only booking
$satsatDates = array:2 [▼
0 => array:3 [▼
"from" => "2017-07-01"
"to" => "2017-09-02"
"satsat" => true
]
1 => array:3 [▼
"from" => "2018-06-30"
"to" => "2018-09-01"
"satsat" => true
]
]
// And I want to merge these into today to a year range and split them up
$start = Carbon::now();
$end = Carbon::now()->addYear();
// How do I split them so I can have this results
$dates = [
[
'from' => '2017-07-01',
'to' => '2017-09-02',
'satsat' => true
],
[
'from' => '2017-09-03'
'to' => '2018-06-29',
'satsat' => false,
],
[
"from" => "2018-06-30"
"to" => "2018-09-01",
'satsat' => true
]
];
Please suggest how do I solve this or where should I ask to solve this or what should I do to solve this.
Thanks!
Loop through $satsatDates, turn from and to into Carbon instances, see if from is greater then and equal to $start and to is less than or equal to $finish and push them into an array.
Please or to participate in this conversation.