A
A
Anton2018-03-16 14:08:21
PHP
Anton, 2018-03-16 14:08:21

How to get a quantity from an array?

There is such a code that displays products - a link, a name, a picture ...
How can I display the number of such products?

<?if(!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED!==true)die();?>

<script type="text/javascript">
  var sCurPage = '<?= CUtil::JSescape($APPLICATION->GetCurPageParam('a', array('a', 'sessid', 'move', 'moveto', 'del')))?>&'+'<?= bitrix_sessid_get()?>';
  var sMessConfirmDel = '<?= CUtil::JSescape(GetMessage('ASD_TPL_FAV_DEL_CONF'))?>';
</script>

<?if (!empty($arResult['CURRENT_FOLDER'])):?>
<h3><?= $arResult['CURRENT_FOLDER']['NAME']?></h3>
<?endif;?>

<?if (!empty($arResult['FAVS'])):?>
  <?
  $moveOptions = '';
  foreach ($arResult['FOLDERS'] as $ID => $arFolder)
  {
    if ($arFolder['ID'] != $arParams['FOLDER_ID'])
      $moveOptions .= '<option value="'.$ID.'">'.$arFolder['NAME'].'</option>'."\n";
  }

  ?>
  <?foreach ($arResult['FAVS'] as $ID => $arItem):?>
  <?if (empty($arItem)) continue;?>
  <div class="asd_fav_item">
    <?if (strlen($arItem['PREVIEW_PICTURE_RESIZED']['src'])){?><a href="<?= $arItem['DETAIL_PAGE_URL']?>"><img src="<?= $arItem['PREVIEW_PICTURE_RESIZED']['src']?>" alt="" /></a><?}?>
    <a href="<?= $arItem['DETAIL_PAGE_URL']?>favorite/"><?= $arItem['NAME']?></a><br/><?= print_r ($arItem)?>
    <?= $arItem['PREVIEW_TEXT']?>
    <div class="asd_clear"></div>
    <?if ($arResult['CAN_EDIT'] == 'Y'):?>
    <div class="asd_fav_menu">
      <?if ($arParams['ALLOW_MOVED'] == 'Y'):?>
      <a href="#" class="asd_fav_move" id="asd_fm_<?= $ID?>"><?= GetMessage('ASD_TPL_FAV_MOVE')?></a>
      <select id="asd_fs_<?= $ID?>">
        <option val="">...</option>
        <?= $moveOptions?>
      </select> |
      <?endif;?>
      <a href="#" class="asd_fav_delete" id="asd_fd_<?= $ID?>"><?= GetMessage('ASD_TPL_FAV_DEL')?></a>
    </div>
    <?endif;?>
  </div>
  <?endforeach;?>

  <?if (strlen($arResult['NAV_STRING']) > 0):?>
  <div class="asd_fav_pagen">
    <?= $arResult['NAV_STRING']?>
  </div>
  <?endif;?>

<?elseif ($arParams['FOLDER_ID'] > 0):?>
  <?= GetMessage('ASD_TPL_FAV_EMPTY')?>
<?else:?>
  <?= GetMessage('ASD_TPL_FAV_NOTHING')?>
<?endif;?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nick Sdk, 2018-03-16
@anton99zel

probably before the code to insert something like

<div class="asd_fav_item_count">Количество товаров: <b><?= count($arResult['FAVS']) ?></b></div>

Z
zim32, 2018-03-16
@zim32

count(array)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question