note 15118 deleted from function.mkdir by aidan

From: Date: Sun, 03 Oct 2004 13:40:58 +0000
Subject: note 15118 deleted from function.mkdir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77849@lists.php.net to get a copy of this message
Note Submitter: KilerCris at Mail dot com ---- I noticed that this function will only attempt to create the last directory in the path, so mkdir("./newdir1/newdir2/newdir2",0700); won't work. I wrote this function to do it. function mkpath($path,$mode = 0700) { $dirs = explode("\\",realpath($path)); $path = $dirs[0]; for($i = 1;$i < count($dirs);$i++) { $path .= "/".$dirs[$i]; if(!is_dir($path)) mkdir($path,$mode); } } Note: I wrote this on windows, where realpath starts with x:\ (x being drive letter)

« previous php.notes (#77849) next »