I'm wondering how to write the if
statement in the following block in a better way. It's supposed to operate when $a
is 14, 22, 30 and for all following values at intervals of 8, up to some limit. The current way is obviously not good since the action must be performed each time that periodic pattern is fulfilled, and this would require many, many OR operators.
if($a == 14 || $a == 22 || $a == 30 || $a == 38 || $a == 46... until some number){
do something...
}
if (isSomething($a)) { do something ... }
and then you can solve that problem inisSomething
, ideally with the solution @Winston Ewert proposed. – back2dos Sep 25 '14 at 06:49