note 68272 added to function.mkdir
| From: | malmsteenforceattlendotpl at osu1 dot php dot net | Date: | Thu, 20 Jul 2006 10:39:47 +0000 |
| Subject: | note 68272 added to function.mkdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114966@lists.php.net to get a copy of this message | ||
I have trouble with recursively of mk_dir function ,with slashes and backslashes, so I`ve solved
this below :
<?
function mkpath($path)
{
$dirs=array();
$path=preg_replace('/(\/){2,}|(\\\){1,}/','/',$path); //only forward-slash
$dirs=explode("/",$path);
$path="";
foreach ($dirs as $element)
{
$path.=$element."/";
if(!is_dir($path))
{
if(!mkdir($path)){ echo "something was wrong at : ".$path; return 0; }
}
}
echo("<B>".$path."</B> successfully created");
}
mkpath("./dir1\dir2/dir3\\\dir4////dir5"); //this works without errors
?>
----
Server IP: 195.136.184.34
Probable Submitter: 213.134.170.155
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mkdir.php
Edit -- http://master.php.net/note/edit/68272
Del: integrated -- http://master.php.net/note/delete/68272/integrated
Del: useless -- http://master.php.net/note/delete/68272/useless
Del: bad code -- http://master.php.net/note/delete/68272/bad+code
Del: spam -- http://master.php.net/note/delete/68272/spam
Del: non-english -- http://master.php.net/note/delete/68272/non-english
Del: in docs -- http://master.php.net/note/delete/68272/in+docs
Del: other reasons-- http://master.php.net/note/delete/68272
Reject -- http://master.php.net/note/reject/68272
Search -- http://master.php.net/manage/user-notes.php