you could use the modulus operator
for(int i = 0; i < 500; i++)
{
if(i % 5 == 0)
{
//do your stuff here
}
}
More Related Contents:
- FOR loop performance in PHP
- Multiple index variables in PHP foreach loop
- PHP: for-loops and if-statement
- Loop or no loop? [closed]
- PHP loop blocking the rest of the code to execute [closed]
- Increment number php every next number
- How does PHP ‘foreach’ actually work?
- Single result from database using mysqli
- PHP: How do you determine every Nth iteration of a loop?
- How do I iterate over the results in a MySQLi result set?
- PHP Foreach Pass by Reference: Last Element Duplicating? (Bug?) [duplicate]
- Can you ‘exit’ a loop in PHP?
- How to find the foreach index?
- How do you remove an array element in a foreach loop?
- PHP read sub-directories and loop through files how to?
- PHP hierarchical array – Parents and childs
- Print time in 15-minute increments between two times in the same day
- Looping a multidimensional array in php
- Checking if array is multidimensional or not?
- How can I break an outer loop with PHP?
- PHP foreach loop through multidimensional array [duplicate]
- Loop a multidimensional array and only print two specific column values per row
- for loop vs while loop vs foreach loop PHP
- Insert elements from one array (one-at-a-time) after every second element of another array (un-even zippering)
- Using a variable outside of the while loop (scope)
- How to set an option from multiple options or array with different values to views as selected in select box using PHP
- foreach with three variables add
- PHP array printing using a loop
- Twig for loop for arrays with keys
- PHP – Flushing While Loop Data with Ajax