Re: [PHP] Recursively create directories

2001-05-15 Thread Adam Wright

This should do what you want...

$dir = dir1/dir2/dir3/dir4;
$dir_array = explode(/,$dir);
$full_path = ;

foreach($dir_array as $current_dir) {
  $full_path .= /$current_dir;

   if (!is_dir($DOCUMENT_ROOT . $full_path)) {
  mkdir($DOCUMENT_ROOT./ .$full_path,0700);
   }
}

adamw

- Original Message - 
From: Darin Isola [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 14, 2001 8:01 PM
Subject: [PHP] Recursively create directories


 hi all,
 
 does anyone have a function to recursively create directories?
 
 heres what I have so far:
 
 $dir = dir1/dir2/dir3/dir4;
 $dir_array = explode(/,$dir);
 
 foreach($dir_array as $current_dir) {
if(! is_dir($DOCUMENT_ROOT./.$current_dir) ) {
   mkdir($DOCUMENT_ROOT./.$current_dir,0700);
}
 }
 
 which works, but this will only create these dirs off the document
 root, not recursivley underneth one another.  im getting stuck on how
 to remember what directory has been created and travel down from there.
 
 can anyone help a brother out?
 
 
 __
 Do You Yahoo!?
 Yahoo! Auctions - buy the things you want at great prices
 http://auctions.yahoo.com/
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Recursively create directories

2001-05-15 Thread Philip Hallstrom

If you're on unix, and don't mind a system call you could do:

system(/bin/mkdir -p $dir);

From the man page for mkdir.

-p  Create intermediate directories as required.  If this option is
not specified, the full path prefix of each operand must already exist.
Intermediate directories are created with permission bits of rwxrwxrwx
(0777) as modified by the current umask, plus write and search
permission for the owner.

In article [EMAIL PROTECTED] you write:
hi all,

does anyone have a function to recursively create directories?

heres what I have so far:

$dir = dir1/dir2/dir3/dir4;
$dir_array = explode(/,$dir);

foreach($dir_array as $current_dir) {
   if(! is_dir($DOCUMENT_ROOT./.$current_dir) ) {
  mkdir($DOCUMENT_ROOT./.$current_dir,0700);
   }
}

which works, but this will only create these dirs off the document
root, not recursivley underneth one another.  im getting stuck on how
to remember what directory has been created and travel down from there.

can anyone help a brother out?


__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Recursively create directories

2001-05-15 Thread Markus Fischer


- Original Message -
From: Philip Hallstrom [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, May 15, 2001 7:01 PM
Subject: Re: [PHP] Recursively create directories


 
 foreach($dir_array as $current_dir) {
if(! is_dir($DOCUMENT_ROOT./.$current_dir) ) {
   mkdir($DOCUMENT_ROOT./.$current_dir,0700);
}
 }

Here's my appraoch:

if( ! @is_dir( $this-cachedir)) {
$dirs = split( '/', $this-cachedir);
$createdir = '';
foreach( $dirs as $dir) { $createdir .= '/' . $dir;
@mkdir( $createdir, 0775);}
}

HTH
- Markus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Recursively create directories

2001-05-15 Thread Gregory Hernandez

Hello.

I just registered to the listserv about two weeks (my 1st time typing here).

I'm just curious, if you don't mind me asking.  I'm just trying to learn
more.  But, would someone list any scenarios in which one would want to
create directories recursively by using php?

Thanks in advance.




On 5/14/01 3:01 PM, Darin Isola [EMAIL PROTECTED] wrote:

 hi all,
 
 does anyone have a function to recursively create directories?
 
 heres what I have so far:
 
 $dir = dir1/dir2/dir3/dir4;
 $dir_array = explode(/,$dir);
 
 foreach($dir_array as $current_dir) {
  if(! is_dir($DOCUMENT_ROOT./.$current_dir) ) {
 mkdir($DOCUMENT_ROOT./.$current_dir,0700);
  }
 }
 
 which works, but this will only create these dirs off the document
 root, not recursivley underneth one another.  im getting stuck on how
 to remember what directory has been created and travel down from there.
 
 can anyone help a brother out?
 
 
 __
 Do You Yahoo!?
 Yahoo! Auctions - buy the things you want at great prices
 http://auctions.yahoo.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]