Skip to content
Advertisement

Tag: modulus

Modulus in a PHP loop

I’m currently checking whether an entry in a loop is the third iteration or not, with the following code: How can I check if the loop is in its second and not its third iteration? I have tried $i % 2 == 1 to no avail. Answer Modulus checks what’s the leftover of a division. If $i is 10, 10/2

Advertisement