Answer the question
In order to leave comments, you need to log in
How to iterate over arrays and then merge them into one?
Hello everyone, please tell me how to sort through the arrays and then combine them into one?
now I have like this .. but only one array is displayed
$firstDate = $this->allParties()->pluck('party_day_from')->toArray();
$allDateParty = $this->allParties()->toArray();
$quantityParty = count($allDateParty);
$arrAllParty = [];
for ($i = 0; $i <= $quantityParty; $i++) {
$partyDayFrom = Arr::get($allDateParty, ''.$i.'.party_day_from');
$partyDayBefore = Arr::get($allDateParty, ''.$i.'.party_day_before');
$countDiffDay = $this->diffDate($partyDayFrom, $partyDayBefore);
$rows = array($partyDayFrom);
$addDay = $partyDayFrom;
for ($i = 1; $i <= $countDiffDay; $i++){
$addDay = date('Y-m-d', strtotime($addDay. ' + 1 days'));
array_push($rows, $addDay);
}
array_shift($rows);
}
array_push($arrAllParty, $rows);
Answer the question
In order to leave comments, you need to log in
For each date, join two strings separated by a space and feed into Carbon::parse:
$dayPart = '2018-10-26';
$timePart = '04:00:00';
$date = Carbon::parse("$dayPart $timePart");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question