A
A
Anton2018-02-23 16:33:12
PHP
Anton, 2018-02-23 16:33:12

How to get the first value from an array?

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

Output:
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] => )

I need to display only 107 from this data and I do it like this:
print_r ($arSection[ID]);
But I get 107 1960,it because in this data there is ID 1960 in addition to 107.
How can I display only the first ID?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-02-23
@vetlugins

print_r($arSection[0][ID]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question