
Untitled
By: a guest on
Jan 14th, 2013 | syntax:
None | size: 0.91 KB | hits: 8 | expires: Never
if(!is_dir(dirname(__FILE__) . '/'.$bbb[0])){
mkdir(dirname(__FILE__) . '/'.$bbb[0],0777);
}
$aaa = '502341';//10023049132
$bbb = explode(',',number_format($aaa));
echo $bbb[0];
if(!is_dir(dirname(__FILE__) . '/'.$bbb[0])){
mkdir(dirname(__FILE__) . '/'.$bbb[0],0777);
}
if(!is_dir(dirname(__FILE__) . '/'.$bbb[0]. '/'.$bbb[1])){
mkdir(dirname(__FILE__) . '/'.$bbb[0]. '/'.$bbb[1],0777);
}
...//how to check more $bbb[2], $bbb[3] or even more?
$path = __DIR__;
if (! is_writable($path))
trigger_error("$path is not writeable");
$str = "502341";
$arr = chunk_split($str, 3, "/");
mkdir($path . DIRECTORY_SEPARATOR . $arr, 0777, true);
^--------- Recrusive
<?php
$aaa = "502341";
$bbb = explode(',',number_format($aaa));
print count($bbb); // prints the depth of your folder tree
mkdir(implode("/",$bbb), 0644, true); // creates recursive folder
?>