[Phpwm] Php Script

David Goodwin david at codepoets.co.uk
Tue May 23 17:24:08 BST 2006


Liam wrote:
> Hi There,
>  
> Im new to php ive just completed a 2 day course at open advantage and im 
> a bit stuck.
>  
> i am after a php script to create directories from A05816 TO A10210 
> including all in between.  apparently i need to use loops but didnt' 
> cover it properly as it was only a 2 day course.
>  


for($i=5816; $i<=10210; $i++) {
    $directory_name = sprintf("A%05s", $i);
}


The %05s in the sprintf should do zero padding appropriately, and the 
for loop should do each thing between the two ranges. I'll leave you to 
figure out how to create the directories within the for loop.

(Perhaps a better answer would be to point you to the PHP api :

http://uk.php.net/manual/en/control-structures.for.php
http://uk.php.net/manual/en/function.sprintf.php

as I feel a little like I'm helping you cheat with homework....)



David.

-- 
David Goodwin

[ david at codepoets dot co dot uk ]
[ http://www.codepoets.co.uk       ]



More information about the Phpwm mailing list