$arSelect = Array("ID", "NAME", "DATE_CREATE"); $arFilter = Array("IBLOCK_ID"=>"5", "ACTIVE"=>"Y"); $res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect); while($ob = $res->GetNextElement()){ $arFields = $ob->GetFields(); print_r($arFields); }
$arSelect = Array("ID", "NAME", "PROPERTY_AUTHOR"); $arFilter = Array("IBLOCK_ID"=>"5", "ACTIVE"=>"Y", "PROPERTY_AUTHOR"=>"John Doe"); $res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect); while($ob = $res->GetNextElement()){ $arFields = $ob->GetFields(); print_r($arFields); }
$arOrder = Array("SORT"=>"ASC"); $arSelect = Array("ID", "NAME", "PROPERTY_AUTHOR"); $arFilter = Array("IBLOCK_ID"=>"5", "ACTIVE"=>"Y"); $res = CIBlockElement::GetList($arOrder, $arFilter, false, false, $arSelect); while($ob = $res->GetNextElement()){ $arFields = $ob->GetFields(); print_r($arFields); }In this example, we are selecting the ID, name, and author property of all active elements in information block ID 5 and sorting the results by the "SORT" property in ascending order. We then loop through the results and print out the selected fields.