note 43809 added to function.mkdir
| From: | soren_bonlokke at hotmail dot com | Date: | Sun, 04 Jul 2004 21:58:57 +0000 |
| Subject: | note 43809 added to function.mkdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72546@lists.php.net to get a copy of this message | ||
With this script i managed to create all the folders in a path ex. path: foo/bar/quux this script
will first create foo then bar in foo and the quux in foo/bar:
<?php
$path = $_REQUEST['path'];
$bits = explode("/", $path);
if(is_array($bits)) {
$i = count($bits);
while ($i >= 0 ) {
array_reverse($bits);
$rel_path[] = $bits[$i];
if(is_array($rel_path)) {
$new_path = join("/", $rel_path);
@mkdir("..$new_path");
}
else{
$new_path = $rel_path;
@mkdir("..$new_path");
}
$i = $i - 1;
}
}
else {
mkdir($path);
}
echo "<br><p>Directory successfully created<p>";
?>
----
Manual Page -- http://www.php.net/manual/en/function.mkdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43809
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43809&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43809&report=yes
Search -- http://master.php.net/manage/user-notes.php