I am given an array containing periods for a year as following.
$year = '2016';
$periods = [
[
'name' => "Name One",
'startDate' => '01/01/2016',
'endDate' => '03/31/2016'
],
[
'name' => "Name Two",
'startDate' => '04/01/2016',
'endDate' => '12/31/2016'
]
];
The number of periods may vary, hence, the array periods may have any number of elements (say 5 elements, meaning 5 periods for the given year). Now I need to make sure that the periods do really make up a year, that is, two periods cannot overlap and the periods collectively do sum up to be the specified year.
I've tried many different ways, but failed to come up with any efficient solution at all. I am using Laravel 5, hence Carbon package. But I'll be glad to get this done even in Basic PHP. So all suggestions are welcome
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/204ca8N
via IFTTT
Aucun commentaire:
Enregistrer un commentaire