Skip to content

Instantly share code, notes, and snippets.

@juanpablocs
Last active May 2, 2016 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpablocs/0b26ca50265b7a0d4bc15687a073dbf4 to your computer and use it in GitHub Desktop.
Save juanpablocs/0b26ca50265b7a0d4bc15687a073dbf4 to your computer and use it in GitHub Desktop.
create files and folder recursive
<?php
$folder = "./myfolder";
$bucket = $folder."/bucket";
$max_folders = 11;
$max_files = 5;
$name_file = "file".rand(9999,999999).".txt";
$url_file = "./file.txt";
$number = function($n){ return ($n<10) ? "0{$n}" : $n; };
for ($i=0; $i < $max_folders; $i++) {
$folder_actual = $bucket.$number($i);
create_folder($folder_actual);
if(count(scan_dir($folder_actual))<$max_files){
copiar($url_file, "{$folder_actual}/{$name_file}");
break;
}
continue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment