All, first post, very exciting
I have a list of dates that are given in the form of a two dimentional
array.
Ex.
var $timeOfYear = array(
1 =array(
'name' ='begining',
'start' ='1/1',
'end' ='5/31'
),
2 =array(
'name' ='end',
'start' ='6/1',
'end' ='12/31'
),
3 =array(
'name' ='special fun time',
'start' ='3/21',
'end' ='6/20'
)
);
Now, I want to take the current date and find what period it falls
into. Obviously, this is a very simple case and will be more
complicated in practice... Note that some periods overlap, in this
case we fall into the shortest period.
My idea was to sort the array from shortest period to longest, then
iterate until I find a match. I don't really know the best way to do
that in PHP. Thanks in advance!
I have a list of dates that are given in the form of a two dimentional
array.
Ex.
var $timeOfYear = array(
1 =array(
'name' ='begining',
'start' ='1/1',
'end' ='5/31'
),
2 =array(
'name' ='end',
'start' ='6/1',
'end' ='12/31'
),
3 =array(
'name' ='special fun time',
'start' ='3/21',
'end' ='6/20'
)
);
Now, I want to take the current date and find what period it falls
into. Obviously, this is a very simple case and will be more
complicated in practice... Note that some periods overlap, in this
case we fall into the shortest period.
My idea was to sort the array from shortest period to longest, then
iterate until I find a match. I don't really know the best way to do
that in PHP. Thanks in advance!
Comment