You want to make it easy for yourself (and potentially other users) to understand what your code is doing, and what you are thinking when you wrote it. Imagine asking for help, imagine outputting debug code or imagine returning to fix a bug 12 months after you last touched the code. Which will be the best and fastest for you/others to understand?
If your code requires that you "For each year, display the data" then the first is more logical. If your thinking is "I need to gather all the measures together, then I'll process those" then go for the second option. If you need to re-order by year, then go the first.
Based on your example above, though the way I'd handle the above is probably:
$array[$year][$month] = $measure;
You don't need a specific "measure" element. Or if you do have two elements per month:
$array[$year][$month] = array('measure' => $measure, 'value'=>$value);
or
$array[$year][$month]['measure'] = $measure;
$array[$year][$month]['value'] = $value;
Then you can go:
for($year = $minYear; $year <= $maxYear; $year++) { // Or "foreach" if consecutive
for ($month = 1; $month <= 12; $month++) {
if (isset($array[$year][$month])) {
echo $array[$year][$month]['measure']; // You can also check these exist using isset if required
echo $array[$year][$month]['value'];
} else {
echo 'No value specified'
}
}
}
Hope that helps with your thinking.