Jump to content

How to use loops


horsebox

Recommended Posts

I don't really know how to use loops I've been using the for loop for everything but I keep running into the same problem. When I need to do something once inside the loop like for example echo $variable it does it 50 times because its inside the loop. How do you do something only once when you're inside a loop thats set to repeat multiple times?

 

For example say I have the loop

for ($ibr=0; $ibr<=10; $ibr++) { $var[$ibr] = $ibr + 4; echo $variable; }

or whatever and need to repeat the $ibr + 4 part 10 times but only need to echo the $variable once what would I do? The way it is there it will echo the $variable 10 times.

Link to comment
https://forums.phpfreaks.com/topic/198857-how-to-use-loops/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.