T
T
tumaniYO2018-12-06 10:10:00
1C-Bitrix
tumaniYO, 2018-12-06 10:10:00

How to remove duplicates from bitrix array?

There is a simple output filter, but there are elements with the same name in the block. Actually the question is how to modernize the code in order to get rid of repeated names, it is enough to mention only the first element.

$arFields = array();
                $arFilter = Array("IBLOCK_ID"=>'15','PROPERTY_157'=>$arElement[ID], "ACTIVE"=>'Y');
                $res = CIBlockElement::GetList(Array('NAME'=>'asc'), $arFilter, false, false, array('ID','NAME'));
                while($ob = $res->GetNextElement()){
    $arFields = $ob->GetFields();
    echo ''.$arFields[NAME].'&nbsp';
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2018-12-06
@tumaniYO

We carefully read the documentation for CIblockElement::getList() .
Array of fields to group the element. If the fields are specified, then the selection is grouped by them (in this case, the arSelectFields parameter will be ignored), and the CNT field is added to the result - the number of grouped elements. If you specify an empty array as arGroupBy, the method will return the number of CNT elements by filter. You can group by the fields of the element, as well as by the values ​​of its properties. To do this, you must specify PROPERTY_ as one of the grouping fields, where PROPERTY_CODE is the ID or symbolic code of the property.
Optional. Default is false - records are not grouped.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question