note 60814 deleted from function.mkdir by nlopess
| From: | nlopess@php.net | Date: | Wed, 18 Jan 2006 19:25:39 +0000 |
| Subject: | note 60814 deleted from function.mkdir by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102042@lists.php.net to get a copy of this message | ||
Note Submitter: bbogovich at tdc-group dot com
----
windows-friendly version, checks for directory existence to avoid cluttering up the error log with
warnings
<?php
function mkdir_recursive($dirName){
$newDir = '';
if (DIRECTORY_SEPARATOR=="\\")
$regexp = "/\\\\/";
else
$regexp = "/\\//";
$dirParts = preg_split($regexp,$dirName);
foreach($dirParts as $dirPart)
{
if ($newDir=="")
$newDir = $dirPart;
else
$newDir.="\\$dirPart";
if (!preg_match('/\\:/',$dirPart)){ //exclude windows drive root
if (!is_dir($newDir)){
mkdir($newDir);
}
}
clearstatcache();
}
}
?>