function DirsRecursive($path, &$arDirs, $arFilter = array(), $depth = 0) { $depth++; CFileMan::GetDirList($path, $arDirsTmp, $arFiles, $arFilter, array("name" => "asc"), "D"); for ($i = 0, $l = count($arDirsTmp); $i < $l; $i++) { $arDir = $arDirsTmp[$i]; $arDir["DEPTH_LEVEL"] = $depth; $arDirs[] = $arDir; CFileMan::DirsRecursive($arDir["ABS_PATH"], $arDirs, $arFilter, $depth); } }