Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Creates directories based on the array given
- *
- * @param array $structure
- * @param string $path
- * @return void
- */
- function make_dir_tree($structure, $path=__DIR__)
- {
- foreach ($structure as $folder => $sub_folder)
- {
- // Folder with subfolders
- if (is_array($sub_folder))
- {
- $new_path = "{$path}/{$folder}";
- if ( ! is_dir($new_path)) mkdir($new_path);
- call_user_func(__FUNCTION__, $sub_folder, $new_path);
- }
- else
- {
- $new_path = "{$path}/{$sub_folder}";
- if ( ! is_dir($new_path)) mkdir($new_path);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement