SQL does the trick.
$myarray = array();
$result = mysql_query("SELECT timestamp, count(id) FROM xpto GROUP BY timestamp");
while ($row = mysql_fetch_array($result))
$myarray[$row[0]]=$row[1];
If you want full information instead of counting:
$myarray = array();
$result = mysql_query("SELECT * FROM xpto ORDER BY timestamp");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$timestamp=$row['timestamp'];
unset($row['timestamp']);
$myarray[$timestamp][]=$row;
}
Now you have this array as a result:
[2013-07-23 10:32:31] => array (
array (
'id'=>2,
'parameter'=>54,
'sensor_id'=>65,
),
array (
'id'=>3,
'parameter'=>23,
'sensor_id'=>45,
),
...
Please modify following code based on your database connection type (PDO, etc)