U
U
usdbuy2019-10-18 16:35:50
Laravel
usdbuy, 2019-10-18 16:35:50

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?
5da9bf83e5938438447070.jpeg
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);

this is what my code outputs, does not add the remaining arrays to the final array
5da9bfa560f48669486790.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-10-18
@Alex_Wells

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");

And in general it is impossible to give dates normally? This is not a standard, this is some kind of game.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question