Created
March 11, 2011 03:03
-
-
Save sp3c73r2038/865381 to your computer and use it in GitHub Desktop.
mkdir if not exists recursively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function recur_mkdir($path, $seperator = "/"){ | |
if($path){ | |
$folders = explode($seperator, $path); | |
if($folders){ | |
$current_path = ''; | |
foreach($folders as $folder){ | |
$current_path .= $folder.$seperator; | |
if(!file_exists($current_path) && $current_path){ | |
echo "making path {$current_path}","\n"; | |
mkdir($current_path); | |
} | |
} | |
} | |
return true; | |
} | |
else{ | |
return false; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment