Here’s a simplified piece of my array structure. I’m trying to drill down and loop only through the months in the first department contained at the “monthly” level. The problem is, that department’s name is used as the array’s key and that will change per data set.
Is there a better way than calling multiple foreach loops and then breaking the parent loop after it has called its first iteration? At this scaled down version, the code doesn’t look so bad, but this could get out of hand for large more complex data sets.
[
array => overall
array => baseline
n/a
array => monthly
array => some_anonymous_department_name
jan => 77%
feb => 99%
march => 44%
array => some_anonymous_department_name_2
jan => 79%
feb => 33%
march => 45%
]
foreach($this->data['overall']['monthly'] as $dept) {
foreach($dept as $month => $score)
echo $month . '<br />';
break;
}