Код: Выделить всё
foreach ($lostOpportunities_ as $key => $value) {
$existDate = array_search($value->fecha, $datesClosed);
if ($existDate === false) {
if (Carbon::parse($value->fecha)->format('Y') == '2020') {
array_unshift($datesClosed, $value);
} else {
array_push($datesClosed, $value->fecha);
}
}
$_lostOpportunitiesData[$value->fecha] = $value->total;
}
Код: Выделить всё
$datesClosedКод: Выделить всё
Array
(
[0] => 05-01-2021
[1] => 06-01-2021
[2] => 07-01-2021
[3] => 11-01-2021
[4] => 12-01-2021
[5] => 13-01-2021
[6] => 14-01-2021
[7] => 15-01-2021
[8] => 18-01-2021
[9] => 19-01-2021
[10] => 20-01-2021
[11] => 21-01-2021
[12] => 22-12-2020
[13] => 23-12-2020
[14] => 28-12-2020
[15] => 29-12-2020
[16] => 30-12-2020
[17] => 08-01-2021
)
Код: Выделить всё
sort($datesClosed, SORT_STRING);
Код: Выделить всё
Array
(
[0] => 05-01-2021
[1] => 06-01-2021
[2] => 07-01-2021
[3] => 08-01-2021
[4] => 11-01-2021
[5] => 12-01-2021
[6] => 13-01-2021
[7] => 14-01-2021
[8] => 15-01-2021
[9] => 18-01-2021
[10] => 19-01-2021
[11] => 20-01-2021
[12] => 21-01-2021
[13] => 22-12-2020
[14] => 23-12-2020
[15] => 28-12-2020
[16] => 29-12-2020
[17] => 30-12-2020
)
Подробнее здесь: https://stackoverflow.com/questions/658 ... d-as-d-m-y
Мобильная версия