0
$path-/home/acname/public_html/storage
$array= (0,1,2,3,4,5,6,7,8,9,a,b, etc.. z);??

using mkdir(); ???

I want to make directories named 0-9 and a-z each with subdirectories in each one 0-z;

eg:

/home/acname/public_html/storage/0/0

all the way to

/home/acname/public_html/storage/9/z

and

/home/acname/public_html/storage/a/0

all the way to

/home/acname/public_html/storage/a/z

continue until ~~~

/home/acname/public_html/storage/z/0

all the way to

/home/acname/public_html/storage/z/z

This will be a one timer I think but far faster than doing it via an ftp client. Figuring this out myself would take longer than the ftp client method! I will learn in the process too.

Thanks in advance!

sled
  • 14,525
  • 3
  • 42
  • 70
Jim_Bo
  • 317
  • 5
  • 17

2 Answers2

1
<?php
   $chars = array(0,1,2,3,4..... ,'x','y','z'); // too lazy to type them all out
   foreach($chars as $first) {
      mkdir("/home/acname/public_html/storage/{$first}");
      foreach($chars as $second) {
          mkdir("/home/acname/public_html/storage/{$first}/{$second}");
      }
   }
?>
Marc B
  • 356,200
  • 43
  • 426
  • 500
1
$names = array_merge(range(0,9), range('a', 'z'));
$path  = '/home/acname/public_html/storage/';

foreach($names as $cName) {
  mkdir($path . $cName);
  foreach($names as $cName2) {
    mkdir($path . $cName . '/' . $cName2);
  }
}
sled
  • 14,525
  • 3
  • 42
  • 70
  • Pehaps you can help me with this one too: http://stackoverflow.com/questions/3704165/php-alpha-sort-lines-from-several-files-in-one-directory-and-save-them-to-files – Jim_Bo Sep 13 '10 at 22:59
  • THANK YOU BY THE WAY! Answered and +1 – Jim_Bo Sep 13 '10 at 23:05