note 51418 deleted from function.mkdir by didou
| From: | didou@php.net | Date: | Wed, 30 Mar 2005 15:25:01 +0000 |
| Subject: | note 51418 deleted from function.mkdir by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-87185@lists.php.net to get a copy of this message | ||
Note Submitter: contrains at jadephoenix dot org
Reason: useless
----
Recursive mkdir() for PHP4 and up.
I know there was one posted below, but *shrugs* I just thought this'd be useful. ^^
<?php
function lmkdir($directory, $chmod=0777) {
$dir_array = explode("/", str_replace("\\", "/", $directory));
$dir_temp_array = array();
$results = array();
foreach($dir_array as $dir) {
$dir_temp_array[] = $dir;
$implode = implode("/", $dir_temp_array);
if(in_array($implode, array("..", ".", "")) ||
preg_match('/^[a-z]:$/i', $implode)) continue;
if(!file_exists($implode)) $results[] = mkdir($implode, $chmod);
}
if(array_sum($results) == count($results)) return TRUE;
else return FALSE;
}
?>
Oh, and the l in lmkdir() stands for the letter that starts my name. I just always do that when I
make a function.
~Lauren