E
E
eskrano2015-10-01 22:40:13
PHP
eskrano, 2015-10-01 22:40:13

How to shorten something like this?

Hello. There is a delusional condition

if ($i == 3 OR $i == 6 OR $i == 9 OR $i == 12 OR $i == 15 OR $i == 18 OR $i == 21 OR $i == 24 OR $i == 27 OR $i == 30) {
//
}

how can this be shortened? I know that I need the remainder of the division, but I can’t figure out how to set it correctly. Weak in math.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eskrano, 2015-10-01
@eskrano

I decided $i % 3 == 0 myself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question