Sunday, September 15, 2013

[PHP] use php to create folder named from "000", "001" to "390"

for example,
i want create 390 folder named with "000","001","002","003","004"......."390"

At the beginning i named them one by one,
but i think that's too stupid,
does any method for me to save the time ?
I am so lazy..

 So i write that code for creating folder,
just for a sharing:

<?php
for ($i =0; $i<=390; $i++){
$filename = $i;
if ($filename < 10){ $filename = "00".$filename; }
else if ($filename >= 10 && $filename <= 100){ $filename = "0".$filename; }
else { $filename = $filename; }
mkdir($filename, 0, true);
}
?>

Result:
 

No comments :

Post a Comment