Ben, buna benzer bir dizi var
[4] => Common_Model Object
(
[id] => 4
[name] =>
[date_created] =>
[last_updated] =>
[user_id_updated] =>
[_table] =>
[_aliases] => Array
(
[id] => 4
[name] =>
[date_created] =>
[date_updated] =>
[user_id_updated] =>
[rating] => 3
[recipe_id] => 5
)
[_nonDBAliases] => Array
(
)
[_default] => Array
(
)
[_related] => Array
(
)
[_enums] =>
[_alsoDelete] => Array
(
)
[_readOnly] => Array
(
[0] => date_updated
)
[_valArgs] => Array
(
)
[_valArgsHash] => Array
(
[default] => Array
(
)
)
[_valAliases] => Array
(
)
[_extraData] => Array
(
)
[_inputs] => Array
(
)
[_tableName] => jm_ratings
[_tablePrefix] =>
[_niceDateUpdated] => 1st Jan 70
[_niceDateCreated] => 1st Jan 70
[_fetchAdminData] =>
[_mCache] =>
[_assets] => Array
(
)
)
[3] => Common_Model Object
(
[id] => 3
[name] =>
[date_created] =>
[last_updated] =>
[user_id_updated] =>
[_table] =>
[_aliases] => Array
(
[id] => 3
[name] =>
[date_created] =>
[date_updated] =>
[user_id_updated] =>
[rating] => 1
[recipe_id] => 5
)
[_nonDBAliases] => Array
(
)
[_default] => Array
(
)
[_related] => Array
(
)
[_enums] =>
[_alsoDelete] => Array
(
)
[_readOnly] => Array
(
[0] => date_updated
)
[_valArgs] => Array
(
)
[_valArgsHash] => Array
(
[default] => Array
(
)
)
[_valAliases] => Array
(
)
[_extraData] => Array
(
)
[_inputs] => Array
(
)
[_tableName] => jm_ratings
[_tablePrefix] =>
[_niceDateUpdated] => 1st Jan 70
[_niceDateCreated] => 1st Jan 70
[_fetchAdminData] =>
[_mCache] =>
[_assets] => Array
(
)
)
[2] => Common_Model Object
(
[id] => 2
[name] =>
[date_created] =>
[last_updated] =>
[user_id_updated] =>
[_table] =>
[_aliases] => Array
(
[id] => 2
[name] =>
[date_created] =>
[date_updated] =>
[user_id_updated] =>
[rating] => 1
[recipe_id] => 5
)
[_nonDBAliases] => Array
(
)
[_default] => Array
(
)
[_related] => Array
(
)
[_enums] =>
[_alsoDelete] => Array
(
)
[_readOnly] => Array
(
[0] => date_updated
)
[_valArgs] => Array
(
)
[_valArgsHash] => Array
(
[default] => Array
(
)
)
[_valAliases] => Array
(
)
[_extraData] => Array
(
)
[_inputs] => Array
(
)
[_tableName] => jm_ratings
[_tablePrefix] =>
[_niceDateUpdated] => 1st Jan 70
[_niceDateCreated] => 1st Jan 70
[_fetchAdminData] =>
[_mCache] =>
[_assets] => Array
(
)
)
Ben [rating]
toplayın ve ortalamasını almak isteyen. Ama PHP ile bunu nasıl bilmiyorum, benim girişimi, bu gibi görünüyor
<?php
foreach ($rt as $rating) {
$total = $rating->rating + $rating->rating
}
$total / count($rt);
?>