I have a calculation like this in my code
foreach ($result as $point) {
@$pointTotals[$point->date][$point->app_id] += $point->revenue;
}
So I would like to avoid the @ symbol here and would like to use array_get instead. But will this support dynamic indexes and can I ue it like this ?
foreach ($result as $point) {
$existingPoint = array_get($pointTotals, $point->date.$point->app_id, 0);
$pointTotals[$point->date][$point->app_id] = $existingPoint + $point->revenue;
}
I am not getting any error here and so I think this is working fine. The thing here I can't test this I don't have any data and all are zeros. So I would like to confirm this will work fine with dynamic keys.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire