我有一个对象数组,想要对其中一个属性的值进行求和。下面的图片展示了这个数组的结构:
以下是我的代码,但它并不能正常工作。
print_r($res);//this appear the structure of array,which i will show.
$sum = 0;
foreach($res as $key=>$value){
if(isset($value->sent))
$sum += $value->sent;
}
echo $sum;
$res->intervalStats
。 - Rikesh