Задать вопрос
@anton99zel
29а класс средней школы №7

Как вывести из массива первое значение?

$resSection = CIBlockSection::GetNavChain(false, $ar_res['IBLOCK_SECTION_ID']);
while ($arSection = $resSection->GetNext()) {
$array_sections = $arSection;
print_r ($arSection);
}

Выведет:
Array ( [ID] => 107 [~ID] => 107 [TIMESTAMP_X] => 2017-07-07 00:00:20 [~TIMESTAMP_X]
 => 2017-07-07 00:00:20 [MODIFIED_BY] => 11382 [~MODIFIED_BY] => 11382 [DATE_CREATE] => 
2016-09-22 11:22:03 [~DATE_CREATE] => 2016-09-22 11:22:03 [CREATED_BY] => 1 
[~CREATED_BY] => 1 [IBLOCK_ID] => 8 [~IBLOCK_ID] => 8 [IBLOCK_SECTION_ID] => 
[~IBLOCK_SECTION_ID] => [ACTIVE] => Y [~ACTIVE] => Y [GLOBAL_ACTIVE] => Y 
[~GLOBAL_ACTIVE] => Y [SORT] => 500 [~SORT] => 500 [NAME] => Контактные линзы 
[~NAME] => Контактные линзы [PICTURE] => [~PICTURE] => [LEFT_MARGIN] => 9 [~LEFT_MARGIN] => 9 [RIGHT_MARGIN] => 138 [~RIGHT_MARGIN] => 138 
[DEPTH_LEVEL] => 1 [~DEPTH_LEVEL] => 1 [DESCRIPTION] => 
[~DESCRIPTION] => [DESCRIPTION_TYPE] => text [~DESCRIPTION_TYPE] => text [SEARCHABLE_CONTENT] => КОНТАКТНЫЕ ЛИНЗЫ [~SEARCHABLE_CONTENT]
 => КОНТАКТНЫЕ ЛИНЗЫ [CODE] => contact_lenses [~CODE] => contact_lenses
 [XML_ID] => [~XML_ID] => [TMP_ID] => [~TMP_ID] => [DETAIL_PICTURE] =>
 [~DETAIL_PICTURE] => [SOCNET_GROUP_ID] => [~SOCNET_GROUP_ID] => 
[LIST_PAGE_URL] => / [~LIST_PAGE_URL] => / [SECTION_PAGE_URL] => 
/contact_lenses/ [~SECTION_PAGE_URL] => /contact_lenses/ [IBLOCK_TYPE_ID]
 => catalog [~IBLOCK_TYPE_ID] => catalog [IBLOCK_CODE] => [~IBLOCK_CODE] => [IBLOCK_EXTERNAL_ID] => [~IBLOCK_EXTERNAL_ID] => [EXTERNAL_ID] =>
 [~EXTERNAL_ID] => ) Array ( [ID] => 1960 [~ID] => 1960 [TIMESTAMP_X] => 
2017-09-01 17:48:34 [~TIMESTAMP_X] => 2017-09-01 17:48:34 [MODIFIED_BY] => 11844 [~MODIFIED_BY] => 11844 [DATE_CREATE] => 2016-12-13 10:25:00 
[~DATE_CREATE] => 2016-12-13 10:25:00 [CREATED_BY] => 7995 [~CREATED_BY]
 => 7995 [IBLOCK_ID] => 8 [~IBLOCK_ID] => 8 [IBLOCK_SECTION_ID] => 107 
[~IBLOCK_SECTION_ID] => 107 [ACTIVE] => Y [~ACTIVE] => Y [GLOBAL_ACTIVE] => Y 
[~GLOBAL_ACTIVE] => Y [SORT] => 400 [~SORT] => 400 [NAME] =>
По типу [~NAME] => По типу [PICTURE] => [~PICTURE] => [LEFT_MARGIN] 
=> 12 [~LEFT_MARGIN] => 12 [RIGHT_MARGIN] => 29 [~RIGHT_MARGIN] =>
 29 [DEPTH_LEVEL] => 2 [~DEPTH_LEVEL] => 2 [DESCRIPTION] =>
Контактные линзы по типу

[~DESCRIPTION] =>

Контактные линзы по типу

[DESCRIPTION_TYPE] => html [~DESCRIPTION_TYPE] =>
 html [SEARCHABLE_CONTENT] => ПО ТИПУ КОНТАКТНЫЕ ЛИНЗЫ ПО 
ТИПУ [~SEARCHABLE_CONTENT] => ПО ТИПУ КОНТАКТНЫЕ ЛИНЗЫ 
ПО ТИПУ [CODE] => po_tipu [~CODE] => po_tipu [XML_ID] => [~XML_ID] 
=> [TMP_ID] => [~TMP_ID] => [DETAIL_PICTURE] => [~DETAIL_PICTURE] 
=> [SOCNET_GROUP_ID] => [~SOCNET_GROUP_ID] => [LIST_PAGE_URL] 
=> / [~LIST_PAGE_URL] => / [SECTION_PAGE_URL] =>
 /contact_lenses/po_tipu/ [~SECTION_PAGE_URL] => /contact_lenses/po_tipu/ [IBLOCK_TYPE_ID] =>
 catalog [~IBLOCK_TYPE_ID] => catalog [IBLOCK_CODE] => [~IBLOCK_CODE] => 
[IBLOCK_EXTERNAL_ID] => [~IBLOCK_EXTERNAL_ID] => [EXTERNAL_ID] => 
[~EXTERNAL_ID] => )

Мне из этих данных вывести нужно только 107 и делаю это так:
print_r ($arSection[ID]);
Но получаю 107 1960, так как в этих данных есть кроме 107 ID 1960.
Как вывести только первый ID?
  • Вопрос задан
  • 95 просмотров
Подписаться 1 Простой 1 комментарий
Пригласить эксперта
Ответы на вопрос 1
print_r ($arSection[0][ID]);
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы