Answer the question
In order to leave comments, you need to log in
How not to display empty values in an array (Bitrix)?
Bitrix code
<?$arSelect = Array("ID","PROPERTY_TIME");$arFilter = Array("IBLOCK_ID"=>34);$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>550), $arSelect);while($ob = $res->GetNextElement()){ $arFields = $ob->GetFields();
echo ($arFields[PROPERTY_TIME_VALUE]).", ";
}?>
Answer the question
In order to leave comments, you need to log in
You need to check for empty value in $arFields['PROPERTY_TIME_VALUE']. If empty, then continue .
A better option is to add a check for a non-empty value to $arFilter. Alternatively '!TIME' => false
echo (!empty($arFields[PROPERTY_TIME_VALUE]))?$arFields[PROPERTY_TIME_VALUE].", ":"";
For starters: writing everything in one line is not the best manner.
2: PROPERTY_TIME_VALUE it is desirable to wrap "PROPERTY_TIME_VALUE" in quotes, of course, if it is not a constant
3: Add a check for the value
$arSelect = Array("ID","PROPERTY_TIME");
$arFilter = Array("IBLOCK_ID"=>34);
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>550), $arSelect);
while($ob = $res->GetNextElement()){
$arFields = $ob->GetFields();
if( !empty($arFields["PROPERTY_TIME_VALUE"]) )
echo ($arFields["PROPERTY_TIME_VALUE"]).", ";
// или:
// if( empty($arFields["PROPERTY_TIME_VALUE"]) ) continue;
// echo ($arFields["PROPERTY_TIME_VALUE"]).", ";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question