For some inexplicable reason, code that used to work no longer does.
foreach($result as $movieid => &$ratings)
{
$rat = $prio = $count = $c = 0;
print_r($ratings);
foreach($ratings as $name => &$data)
{
$rat += $data['value'] * $data['priority'];
$prio += $data['priority'];
$result[$movieid][$name] = (float)$data['value'];
$count += $data['count'];
++$c;
}
if($prio > 0)
$result[$movieid]['Average'] = $rat / $prio;
if($c > 0)
$result[$movieid]['Count'] = $count / $c;
}
For some reason, it registers the 'Count' as 0, even though print_r() reveals that the 'count' members in $ratings[] are nonzero.
Explicit casts to int/float don't help.
EDIT: Hmm, removing the & from &$data made it work again. So why did it stop working when I upgraded PHP, when it worked just perfectly before? What else did break?