Hm... I just put together a test script... I think I know what the problem is.
$result = array(
array(
'number 1' => array('value' => 1,'count' => 5),
'number 2' => array('value' => 2,'count' => 3),
'number 3' => array('value' => 3,'count' => 2),
'number 4' => array('value' => 4,'count' => 1)
),
array(
'number 1' => array('value' => 1,'count' => 1),
'number 2' => array('value' => 2,'count' => 8),
'number 3' => array('value' => 3,'count' => 4),
'number 4' => array('value' => 4,'count' => 0)
));
foreach($result as $id => &$ratings)
{
foreach($ratings as $name => &$data)
{
$result[$id][$name] = (float)$data['value'];
print_r($data);
}
}
The line
$result[$id][$name] = (float)$data['value'];
is the same exact thing as
$data = (float)$data['value'];
which means that $data['count'] doesn't exist - $data is just a number, not an array.
edit: I'm guessing at the approximate structure of the $result array - if it's different I could be wrong.
edit2: If you moved the $count += ... line up one line, it would probably work fine.