A
A
Anton2017-09-14 19:59:44
JavaScript
Anton, 2017-09-14 19:59:44

How to eliminate duplicates and calculate the total number of elements?

Here is the code that displays the element IDs.
How to exclude duplicates from it and calculate the total number of elements?

<?
$arSelect = Array('ID',"PROPERTY_OTHER_COLORS");
$arFilter = Array("IBLOCK_ID"=>8, 'SECTION_ID'=>2208,"ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", '>=CATALOG_QUANTITY' => 1);
$res_count = CIBlockElement::GetList(Array(), $arFilter, Array(), Array("nPageSize"=>50), $arSelect);
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>900), $arSelect);
while($ob = $res->GetNextElement()){ 
 $arFields = $ob->GetFields();  
print_r ($arFields[ID]);
echo "</br>";
}
?>

On the screen
40413
40413
40414
40414
40420
40422
40422
40422

From my example, you need to get 4.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2019-05-29
@Sedbol

Well, there is no such element, so there is nowhere to get the text from. Make a check

let textr = '';

if (runRo && runRo.length > 0) {
    textr = runRo.innerHTML;
}

A
Alexey Emelyanov, 2017-09-14
@babarun

$arSelect = Array('ID');
$arFilter = Array("IBLOCK_ID"=>8, 'SECTION_ID'=>2208,"ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", '>=CATALOG_QUANTITY' => 1);
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>900), $arSelect);
while($ob = $res->GetNextElement()){ 
 $arFields = $ob->GetFields();  
print_r ($arFields[ID]);
echo "</br>";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question