PHP Function to generate folder name based on id or a number. Use the following function to create folder name as desired based on your needs.
function generateFolderName($no) {
$id = ceil(($no/1000))-1; //Here "1000" defines the folder change after 1000 files
$folder = "";
while($id >= 0) {
$folder = chr($id % 26 + 65) . $folder;
$id = floor($id / 26) - 1;
}
return strtolower($folder);
}
This makes folder name change after 1000 files. Hence 1-1000 will return "a" and 1001-2000 will return "b" and hence like that.
function generateFolderName($no) {
$id = ceil(($no/1000))-1; //Here "1000" defines the folder change after 1000 files
$folder = "";
while($id >= 0) {
$folder = chr($id % 26 + 65) . $folder;
$id = floor($id / 26) - 1;
}
return strtolower($folder);
}
This makes folder name change after 1000 files. Hence 1-1000 will return "a" and 1001-2000 will return "b" and hence like that.
No comments:
Post a Comment