<?$counter = 0;?>
<?foreach($arResult["ITEMS"] as $arItem):?>
<?if($counter >= 5){break;}?>
<h1><?=$arItem["NAME"]?></h1>
<?$counter++?>
<?endforeach;?>
'SORT_BY1' => 'RAND',
'SORT_ORDER1' => 'RAND',
'NEWS_COUNT' => 5,
<?$counter = 0;
$ar_keys = range(0, count($arResult["ITEMS"])-1);
shuffle($ar_keys);?>
<?foreach($ar_keys as $key):?>
<?if($counter >= 5){break;}?>
<h1><?=$arResult["ITEMS"][$key]["NAME"]?></h1>
<?$counter++?>
<?endforeach;?>