<?php $data = [ 'src' => [ 'Controller' => ['HomeController.php', 'ApiController.php'], 'Entity' => ['User.php', 'Product.php'], 'Kernel.php', ], 'tests' => ['AppTest.php'], 'composer.json', ]; $tree = new RecursiveTreeIterator( new RecursiveArrayIterator($data) ); foreach ($tree as $line) { echo $line . "\n"; } // Output: // |-src // | |-Controller // | | |-HomeController.php // | | \-ApiController.php // | |-Entity // | | |-User.php // | | \-Product.php // | \-Kernel.php // |-tests // | \-AppTest.php // \-composer.json // (also works with RecursiveDirectoryIterator!)
You have javascript disabled. You will not be able to edit any code.