Skip to content

Instantly share code, notes, and snippets.

@sp3c73r2038
Created March 11, 2011 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sp3c73r2038/865381 to your computer and use it in GitHub Desktop.
Save sp3c73r2038/865381 to your computer and use it in GitHub Desktop.
mkdir if not exists recursively
<?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