E
E
eternalfire2017-09-28 16:37:25
PHP
eternalfire, 2017-09-28 16:37:25

How to fill an array with the result of a while loop?

<? if (!CModule::IncludeModule('highloadblock')) continue;
        $ID = 2;
        $hldata = Bitrix\Highloadblock\HighloadBlockTable::getById($ID)->fetch();
        $hlentity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hldata);
        $hlDataClass = $hldata['NAME'].'Table';
        $arResult['CUSTOM'] = [];
        $arFilter = Array(
            Array(
                "LOGIC"=>"AND",
                Array(
                    'UF_XML_ID'=> $arItem['PROPERTIES']['YEAR']['VALUE']
                )
            )
        );
        $result = $hlDataClass::getList(array(
            'select' => array('ID', 'UF_NAME', 'UF_XML_ID'),
            'order' => array('UF_XML_ID' =>'ASC'),
            'filter' => $arFilter,
        ));
        while ($res = $result->fetch()) {
            print_r($res);
        }
    ?>

By displaying the $res array in a loop, we get all the values ​​in full, and below the while only the first7. How to save the result of his work and get the full array after while

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Bille, 2017-09-28
@eternalfire

<? if (!CModule::IncludeModule('highloadblock')) continue;
        $ID = 2;
        $hldata = Bitrix\Highloadblock\HighloadBlockTable::getById($ID)->fetch();
        $hlentity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hldata);
        $hlDataClass = $hldata['NAME'].'Table';
        $arResult['CUSTOM'] = [];
        $arFilter = Array(
            Array(
                "LOGIC"=>"AND",
                Array(
                    'UF_XML_ID'=> $arItem['PROPERTIES']['YEAR']['VALUE']
                )
            )
        );
        $result = $hlDataClass::getList(array(
            'select' => array('ID', 'UF_NAME', 'UF_XML_ID'),
            'order' => array('UF_XML_ID' =>'ASC'),
            'filter' => $arFilter,
        ));
        $arReturn = [];
        while ($res = $result->fetch()) {
            $arReturn[] = $res;
        }
    ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question