开发者

PHP - make a bunch of directories 0-z and sub directories 0-z from an array

$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_开发者_C百科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!


$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);
  }
}


<?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}");
      }
   }
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜