note 68272 deleted from function.mkdir by felipe

From: Date: Mon, 10 Dec 2007 18:05:49 +0000
Subject: note 68272 deleted from function.mkdir by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133254@lists.php.net to get a copy of this message
Note Submitter: malmsteenforce at tlen dot pl ---- 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 ?>

« previous php.notes (#133254) next »