note 43071 deleted from function.mkdir by aidan

From: Date: Sun, 03 Oct 2004 13:37:14 +0000
Subject: note 43071 deleted from function.mkdir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77827@lists.php.net to get a copy of this message
Note Submitter: saint at corenova.com ---- For whatever reason, some of the mkdir_p funcs don't work on my sys. Here's a simple one that seem to work for me: <?php function mkdir_p($target) { if (is_dir($target)||empty($target)) return 1; // best case check first if (file_exists($target) && !is_dir($target)) return 0; if (mkdir_p(substr($target,0,strrpos($target,'/')))) return mkdir($target); // crawl back up & create dir tree return 0; } ?> above handles relative paths as well as absolute paths, no fancy dir name validation check, recurses cleanly. Returns 1: when dir already exists, or successfully made Returns 0: when anything contrary to above.

« previous php.notes (#77827) next »