• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/type/arrayhelper.php
  • Класс: BitrixDiskTypeArrayHelper
  • Вызов: ArrayHelper::getByPath
static function getByPath($array, $path, $defaultValue = null)
{
	if(!is_array($array) && !$array instanceof ArrayAccess)
	{
		throw new ArgumentException("$array is not array or don't implement ArrayAccess");
	}
	
	$pathItems = explode('.', $path);

	$lastArray = $array;
	foreach($pathItems as $pathItem)
	{
		if(!is_array($lastArray) && !$lastArray instanceof ArrayAccess)
		{
			return $defaultValue;
		}

		if(!isset($lastArray[$pathItem]))
		{
			return $defaultValue;
		}

		$lastArray = $lastArray[$pathItem];
	}

	return $lastArray;
}