<?php

// your code goes here

$folders=array(
	"Папка А"=>array(
		"Папка B"=>array(), 
		"Папка C"=>array(
			"Файл 1", 
			"Файл 2", 
			"Файл 3"), 
		"Файл 10", 
		"Файл 11", 
		"Файл 12"), 
	"Файл 20", 
	"Файл 21", 
	"Файл 22", 
	"Папка G"=>array()
);

function walk_tree($tree, $de)
{ 
	$result = '';
	
	foreach ($tree as $key =>$value) 
		if (is_array($value))
		{	
			$result .= $de . "[{$key}]" . PHP_EOL;
			$result .= walk_tree($value, $de . '___');
		}
		else
		{
			$result .= $de . $value . PHP_EOL;
		}
		
	return $result;
}

echo walk_tree($folders, '');