Есть массив объектов Код (Text): $userRating = UserRating::find()->where(['user_id' => $id])->all(); , как просчитать среднее свойства rating?
Код (Text): array(4) { [0]=> object(app\models\UserRating)#118 (10) { ["_attributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(1) ["rating"]=> int(4) ["user_id"]=> int(3) } ["_oldAttributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(1) ["rating"]=> int(4) ["user_id"]=> int(3) } ["_related":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_relationsDependencies":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_errors":"yii\base\Model":private]=> NULL ["_validators":"yii\base\Model":private]=> NULL ["_scenario":"yii\base\Model":private]=> string(7) "default" ["_events":"yii\base\Component":private]=> array(0) { } ["_eventWildcards":"yii\base\Component":private]=> array(0) { } ["_behaviors":"yii\base\Component":private]=> array(0) { } } [1]=> object(app\models\UserRating)#123 (10) { ["_attributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(2) ["rating"]=> int(2) ["user_id"]=> int(3) } ["_oldAttributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(2) ["rating"]=> int(2) ["user_id"]=> int(3) } ["_related":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_relationsDependencies":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_errors":"yii\base\Model":private]=> NULL ["_validators":"yii\base\Model":private]=> NULL ["_scenario":"yii\base\Model":private]=> string(7) "default" ["_events":"yii\base\Component":private]=> array(0) { } ["_eventWildcards":"yii\base\Component":private]=> array(0) { } ["_behaviors":"yii\base\Component":private]=> array(0) { } } [2]=> object(app\models\UserRating)#124 (10) { ["_attributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(3) ["rating"]=> int(4) ["user_id"]=> int(3) } ["_oldAttributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(3) ["rating"]=> int(4) ["user_id"]=> int(3) } ["_related":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_relationsDependencies":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_errors":"yii\base\Model":private]=> NULL ["_validators":"yii\base\Model":private]=> NULL ["_scenario":"yii\base\Model":private]=> string(7) "default" ["_events":"yii\base\Component":private]=> array(0) { } ["_eventWildcards":"yii\base\Component":private]=> array(0) { } ["_behaviors":"yii\base\Component":private]=> array(0) { } } [3]=> object(app\models\UserRating)#125 (10) { ["_attributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(4) ["rating"]=> int(1) ["user_id"]=> int(3) } ["_oldAttributes":"yii\db\BaseActiveRecord":private]=> array(3) { ["id"]=> int(4) ["rating"]=> int(1) ["user_id"]=> int(3) } ["_related":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_relationsDependencies":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_errors":"yii\base\Model":private]=> NULL ["_validators":"yii\base\Model":private]=> NULL ["_scenario":"yii\base\Model":private]=> string(7) "default" ["_events":"yii\base\Component":private]=> array(0) { } ["_eventWildcards":"yii\base\Component":private]=> array(0) { } ["_behaviors":"yii\base\Component":private]=> array(0) { } } } - как в данном массиве просчитать сумму $rating