How would I count every time it hits the 10th number?
10
20
30
40
etc…
when a variable goes from 9->10 i want it to do something
[php]function repup($var){
//“check if 10th number here”
return true/false
}[/php]
How would I count every time it hits the 10th number?
10
20
30
40
etc…
when a variable goes from 9->10 i want it to do something
[php]function repup($var){
//“check if 10th number here”
return true/false
}[/php]
i got it!
[php]function repup($var){
$base = $var / 10;
if($base != 0){
if(is_int($base)){
return True;
} else {
return False;
} else {
return False;
}[/php]
There’s a much easier solution…
[php]
if ($var % 10 === 0) {
return true;
}
[/php]
Thanks!
Will this work also for numbers like 24520?
Sure, test it
[php]
$n = 24520;
$c = $n;
for($i = 0; $i < 5; $i++) {
echo $c . ": " . ($c % $n === 0 ? “true” : “false”) . “\n”;
$c += $n;
}
[/php]
24520: true
49040: true
73560: true
98080: true
122600: true
Sweetness