i have a array that returns some numbers. and i want to add those numbers together and also count them.
here is what i have so far:
<?php
$homepage = file_get_contents('http://graph.facebook.com/215844978437619/reviews');
$parsed = json_decode($homepage,true);
foreach ($parsed['data'] as $key => $values){
$totalRatings1 = $values['rating'] ;
}
?>
what i am trying to do is to sum the $values['rating'] together and also count them.
So that: $totalRatings = sum_array($values['rating']) and $totalCount = count($values['rating'])
but i get lost in the sintax.
any ideas?
Thanks
$totalRatingswill have the aggregated sum of all ratings,$totalRatedwill be the count of how many ratings there are.