Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 14th, 2013  |  syntax: None  |  size: 0.91 KB  |  views: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. if(!is_dir(dirname(__FILE__) . '/'.$bbb[0])){
  2.     mkdir(dirname(__FILE__) . '/'.$bbb[0],0777);
  3. }
  4.  
  5. $aaa = '502341';//10023049132
  6. $bbb = explode(',',number_format($aaa));
  7. echo $bbb[0];
  8. if(!is_dir(dirname(__FILE__) . '/'.$bbb[0])){
  9.     mkdir(dirname(__FILE__) . '/'.$bbb[0],0777);
  10. }
  11. if(!is_dir(dirname(__FILE__) . '/'.$bbb[0]. '/'.$bbb[1])){
  12.     mkdir(dirname(__FILE__) . '/'.$bbb[0]. '/'.$bbb[1],0777);
  13. }
  14. ...//how to check more $bbb[2], $bbb[3] or even more?
  15.        
  16. $path = __DIR__;
  17.  
  18. if (! is_writable($path))
  19.     trigger_error("$path is not writeable");
  20.  
  21. $str = "502341";
  22. $arr = chunk_split($str, 3, "/");
  23. mkdir($path . DIRECTORY_SEPARATOR . $arr, 0777, true);
  24.                                                   ^--------- Recrusive
  25.        
  26. <?php
  27. $aaa = "502341";
  28. $bbb = explode(',',number_format($aaa));
  29. print count($bbb); // prints the depth of your folder tree
  30. mkdir(implode("/",$bbb), 0644, true); // creates recursive folder
  31. ?>