How to call a function for n times in PHP?

Nick M

New member
Use a for statement:

for ($num = 1; $num < 10; $num++)
{
yourfunction();//Runs the Function 12 times
}

or you can do it like this:

//Amount of times You want the function to run
$amount= 10;

for ($num = 1; $num < $amount; $num++)
{
yourfunction();//Runs the function 10 times
}
And remember you need to write the function before this too, outside the curly braces though.
Here is a tutorial to fully understand it:
http://www.bellaonline.com/articles/art21643.asp
 
Back
Top