Answer the question
In order to leave comments, you need to log in
How to select a property from CIBlockResult Object and make an average number?
Hi all.
The bottom line is this: I
select the elements with a filter:
$countOnPage = 3;
$fastUrlsList = array();
$arSelect = Array("ID", "NAME", "PREVIEW_TEXT", "PROPERTY_SPRAV", "DATE_CREATE", "PROPERTY_RATING");
$arFilter = Array("IBLOCK_ID"=>34, "ACTIVE"=>"Y", "PROPERTY_SPRAV"=>$arResult["ID"]);
$res = CIBlockElement::GetList(array("SORT"=>"ASC"), $arFilter, false, array("nPageSize" => $countOnPage), $arSelect);
Answer the question
In order to leave comments, you need to log in
$a = array();
while($item = $res->fetch()){
$a[] = $item['PROPERTY_RATING'];
}
$Rating = array_sum($a) / count($a)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question