So i have an array which is created like this via a loop
foreach ($items as $item)
{
$item_arr[$id]['count'] = $item->rowcount;
}
Now what i want to do is get the sum of the counts. I know i can just use $sum += $item->rowcount; but i was wondering if there was a more efficient way using something like this outside the loop when the foreach is done:
$sum = array_sum($item_arr[]['count']);
But that doesn't work says it doesn't like [], is there a way to do it or is the best way just to keep count in the foreach loop. Just would like to keep the code cleaner and more readable but maybe its a stupid question?