note 26340 added to function.mkdir

From: Date: Sun, 27 Oct 2002 08:42:46 +0000
Subject: note 26340 added to function.mkdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-38615@lists.php.net to get a copy of this message
// mkdirs // makes dirs, even if parents don't exist - they are made, too // checks if this dir exists, then if the parent, then its parent... // -> fast for cases where the parents will exist most times // -> slow if the root dir doesn't exist function mkdirs( $strPath, $nPermission) { strstr( PHP_OS, "WIN") ? $strPathSeparator = "\\" : $strPathSeparator = "/"; $strDirname = substr( $strPath, 0, strrpos( $strPath, $strPathSeparator)); if( is_dir( $strDirname)) { return true; } $arMake = array(); array_unshift( $arMake, $strDirname); do { $bStop = true; $nPos = strrpos( $strDirname, $strPathSeparator); $strParent = substr( $strDirname, 0, $nPos); if( !is_dir( $strParent)) { $strDirname = $strParent; array_unshift( $arMake, $strDirname); $bStop = false; } } while( !$bStop); if( count( $arMake) > 0) { foreach( $arMake as $strDir) { mkdir( $strDir, $nPermission); } } return true; }//function mkdirs( $strPath, $nPermission) -- http://www.php.net/manual/en/function.mkdir.php http://master.php.net/manage/user-notes.php?action=edit+26340 http://master.php.net/manage/user-notes.php?action=delete+26340 http://master.php.net/manage/user-notes.php?action=reject+26340

« previous php.notes (#38615) next »