Let's say that I have some widgets, and each widget has events. Each event has a unique timestamp and a non-unique value.
Since the timestamp is rather large to use as an index (hashing?) I am adding events like this:
$_SESSION['widgets']['datasets'][$i][] =
array('timestamp' => $ts, 'value' => $value);
However, not every widget has an event at every timestamp, so there are gaps. EDIT: that means that maybe widget A is entered Mon, Tue, Wed and field B is entered Mon, Wed, Fri. I will then loop through Mon, Tue, Wed, Thur, Fri, Sat, Sun, and want to know which widget had an event that day and what its value was.
After reading all the events from the database, I loop over all known timestamps, then loop over each widget to see if it has an event with that timestamp.
And there I am probably inefficient.
What's the best way to code this?
for each timestamp
for each widget
if the widget has an entry with the timestamp, get the value <=== how?