note 87696 deleted from function.mkdir by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 19:17:21 +0000 |
| Subject: | note 87696 deleted from function.mkdir by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218713@lists.php.net to get a copy of this message | ||
Note Submitter: t-k-r at o2 dot pl
----
Very simple script, may be useful to someone.
Creating a directory structure liki this:
0 ------ 0
1 1
2 2 -------- 0
3 3 1
4 ... 2
5 3
6 ...
7
[....]
e
f
Used by my as structure to store uploaded files:
someone upload file -> its name + microtime is md5 -> first 3 letters of md5 string are first
3 subfolders in this folder structure, and at least file is stroed with md5 name.
Naturally SQL- or other type - Database is needed to store infos about files position in this
structure.
<?php
for ($a=0;$a<=15;$a++) {
mkdir(dechex($a),0755);
for ($b=0;$b<=15;$b++) {
mkdir(dechex($a).'/'.dechex($b),0755);
for ($c=0;$c<=15;$c++) {
mkdir(dechex($a).'/'.dechex($b).'/'.dechex($c),0755);
}
}
}
?>