I have an array with this structure:
$months = array(
MM => array(
'start' => DD,
'end' => DD,
'type' => (string),
'amount'=> (float),
),
);
MM - month (01-12, line), DD day in the month (01-31, line). Not all months may be in the array. For each month, there is a variable number of subbands with ranges with unique days each. For example, a month has three sub-ranges with three ranges of days, but the days used in these ranges will never overlap or duplicate, each DD value is unique. With one exception, in some ranges the "start" and "end" may coincide (the same day DD), but there will never be two identical "start" days or two identical "end" days for each month.
I need to use this array, looping months and days for each month. Cycle every day in the month, I have to check whether this particular day corresponds to "start" or "end". If the match is true, I also need to get adjacent values.
However, I ran into one problem: how can I find out the key index of a subrange, where is such a match? For example, how do you know if a match matches
$months['09'][3]['start'] == $current_day_in_loop;
or rather:
$months['09'][6]['start'] == $current_day_in_loop;
or another key?
Since I don’t know how many ranges exist for each month, the index key is variable or not at all. How to determine if a matching value is found with a key [3]or [6]? As soon as I know the key, I can use it to search for adjacent values in the same submatrix.