Okay What I want is to basically detect in a loop each time $1 is a multiple of 5. eg. 5, 10, 15, 20 So i need and if statement the divides $i/5 and can detec if it's an even number. Is there a special function in PHP that can do that? Skinny
$i = 0 ; $ismultiple5 = 0 ; while ($i < $final_amount) { // do whatever $i ++ ; $ismultiple5 ++ ; if ($ismultiple5 == 5) { // do multiple of 5 stuff then reset $ismultiple5 $ismultiple5 = 0 ; } } PHP: sounds about right, sorry if my variable naming structure sucks
I'd use the '%' (modulus) operator http://php.net/manual/en/language.operators.arithmetic.php for ($i = 0; $i < 10000; $i++) { if (! ($i % 5)) { # this is a multiple of 5 } else { # this is not a multiple of 5 } } PHP: HTH, cheers!
picouli, your coding is much more elegant than mine & you provide reference. That is how a you are supposed to answer a question. Well done, I've jotted down a few notes but cannot guarantee you that I will follow them.
Thanks to both of you. I opted to use picouli's method. though both definitely looked like the were going to work. Thanks both. rep added. Skinny