note 51418 added to function.mkdir

From: Date: Wed, 30 Mar 2005 15:18:40 +0000
Subject: note 51418 added to function.mkdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-87184@lists.php.net to get a copy of this message
Recursive mkdir() for PHP4 and up. I know there was one posted below, but *shrugs* I just thought this'd be useful. ^^ <?php function lmkdir($directory, $chmod=0777) { $dir_array = explode("/", str_replace("\\", "/", $directory)); $dir_temp_array = array(); $results = array(); foreach($dir_array as $dir) { $dir_temp_array[] = $dir; $implode = implode("/", $dir_temp_array); if(in_array($implode, array("..", ".", "")) || preg_match('/^[a-z]:$/i', $implode)) continue; if(!file_exists($implode)) $results[] = mkdir($implode, $chmod); } if(array_sum($results) == count($results)) return TRUE; else return FALSE; } ?> Oh, and the l in lmkdir() stands for the letter that starts my name. I just always do that when I make a function. ~Lauren ---- Manual Page -- http://www.php.net/manual/en/function.mkdir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51418 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51418&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51418&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51418&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51418&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51418&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51418&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87184) next »