Your question is subjective, in that everyone may have a different approach to the situation you stated, and you are wise to even ask the question; How best to name your variables, classes, etc. Sad to say, I spend more time than I care to admit determining the best variable names that make sense and satisfy the requirements. My ultimate goal is to write code which is 'self documenting'. By writing self-documenting code you will find that it is much easier to add features or fix defects as they arise.
Over the years I have come to find that these practices work best for me:
Arrays: Always plural
I do this so loop control structures make more semantic sense, and are easier to work with.
// With a plural array it's easy to access a single element
foreach ($students as $student) {}
// Makes more sense semantically
do {} (while (count($students) > 0);
Arrays of objects > deep multi-dimensional arrays
In your example your arrays started blowing up to be 3 element deep multi-dimensional arrays, and as correct as Robbie's code snippet is, it demonstrates the complexity it takes to iterate over multi-dimensional arrays. Instead, I would suggest creating objects, which can be added to an array. Note that the following code is demonstrative only, I always use accessors.
class Owner
{
public $year;
public $measure;
public $month;
}
// Demonstrative hydration
for ($i = 1 ; $i <= 3 ; $i++) {
$owner = new Owner();
$owner->year = 2012;
$owner->measure = $i;
$owner->month = rand(1,12);
$owners[] = $owner;
}
Now, you only need to iterate over a flat array to gain access to the data you need:
foreach ($owners as $owner) {
var_dump(sprintf('%d.%d: %d', $owner->month, $owner->year, $owner->measure));
}
The cool thing about this array of objects approach is how easy it will be to add enhancements, what if you want to add an owner name? No problem, simply add the member variable to your class and modify your hydration a bit:
class Owner
{
public $year;
public $measure;
public $month;
public $name;
}
$names = array('Lars', 'James', 'Kirk', 'Robert');
// Demonstrative hydration
for ($i = 1 ; $i <= 3 ; $i++) {
$owner = new Owner();
$owner->year = 2012;
$owner->measure = $i;
$owner->month = rand(1,12);
$owner->name = array_rand($names);
$owners[] = $owner;
}
foreach ($owners as $owner) {
var_dump(sprintf('%s: %d.%d: %d', $owner->name, $owner->month, $owner->year, $owner->measure));
}
You have to remember that the above code snippets are just suggestions, if you rather stick with deep multi-dimensional arrays, then you will have to figure out an element ordering arrangement that makes sense to YOU and those you work with, if you think you will have trouble with the setup six months down the road, then it is best to implement a better strategy while you have the chance.