I believe that when you're using data that is meant to be kept as a collective, it's better to store it in a single data set (such as an associative array or object). The following are examples of structures that can be used to store data sets.
In PHP, as associative arrays:
$owner = array(
'year' => 2012, 'month' => 'July', 'measure' => 3
);
In C#, as hash tables:
Hashtable owner = new Hashtable();
owner.Add("year", 2012);
owner.Add("month", "July");
owner.Add("measure", 3);
In Java, as hash tables:
Hashtable owner = new Hashtable();
owner.put("year", new Integer(2012));
owner.put("month", new String("July"));
owner.put("measure", new Integer(3));
In C#/Java, as objects:
public class Owner {
public int year;
public string month;
public int measure;
}
Owner o = new Owner();
o.year = 2012;
o.month = "July";
o.measure = 3;
In C# and Java, the advantage to using objects over hash tables is that variable types (ie. int or string) can be declared for each field/variable, which will help to prevent errors and maintain data integrity since errors will be thrown (or warnings will be generated) when you attempt to assign the wrong type of data to a field.
In PHP, I find that objects have no real advantages over arrays when storing collections of data because type hinting isn't allows for scalar variables, which means that additional code is required to check/restrict what data is entered in a property, you have to write extra code to declare the class, you can accidentally assign your values to the wrong property by misspelling the name (just the sames as can be done with arrays so it doesn't help with data integrity), and iteration/manipulation of properties requires extra code as well. I also find it easier to work with with associative arrays when converting to/from JSON in PHP.
Based on the code in the question, most often you'll need to add another dimension to the array when you need to access the data via one of the fields or some other criteria (such as a combination of fields or data that the field would map onto).
This is where hash tables and associative arrays are more useful for each of the languages. For example, if you want to organize the owners into groups based on year and month, you can create associative arrays (or hash tables) to do this.
The following PHP example uses PDO and fetchAll to get the information from a database:
$sth = $dbh->prepare("SELECT year, month, measure FROM owners");
$sth->execute();
$rows = $sth->fetchAll(PDO::FETCH_ASSOC);
$data = array();
foreach ($rows as $row) {
$year = $row['year'];
$month = $row['month'];
if (!isset($data[$year])) {
$data[$year] = array();
}
if (!isset($data[$year][$month])) {
$data[$year][$month] = array();
}
array_push($data[$year][$month], $row);
}
An example of how this data might look as code is:
$data = array(
2011 => array(
'July' => array(
array('year' => 2011, 'month' => 'July', 'measure' => 1),
array('year' => 2011, 'month' => 'July', 'measure' => 3)
),
'May' => array(
array('year' => 2011, 'month' => 'May', 'measure' => 9),
array('year' => 2011, 'month' => 'May', 'measure' => 4),
array('year' => 2011, 'month' => 'May', 'measure' => 2)
)
),
2012 => array(
'April' => array(
array('year' => 2012, 'month' => 'April', 'measure' => 7)
)
)
);
You can then access the data using the keys.
$data[2011]['July'];
// array(
// array('year' => 2011, 'month' => 'July', 'measure' => 1),
// array('year' => 2011, 'month' => 'July', 'measure' => 3)
// )
Furthermore, I attempt to keep my objects that represent collections of data minimal when I create them. If you're storing your collections in objects, as you begin to add functions that perform operations on the collections, there will be more code to maintain. There are times when this is necessary, for example if you need to restrict what values can be stored via setters, but if all you're doing is passing data from a user into a database and displaying it on the screen again, then there usually isn't a need for advanced functionality in the data collection and it may make more sense to have the functionality managed elsewhere. For example, View classes can handle displaying data, Model classes can handle extracting data, and Check objects can verify that data can be saved or verify whether or not operations can be performed based on the data in the collection.