Answer the question
In order to leave comments, you need to log in
How to shorten and write this code correctly?
Hello! Please help me shorten and write this code correctly!
$a = 1;
$b = 0;
if ($b === 0 && $a % 7 == 0) {
//
}
if ($b === 1 && $a % 3 == 0) {
//
}
if ($b === 2 && $a % 2 == 0) {
//
}
$a++;
$b
$a
- this is the time, it is executed in my timer
Answer the question
In order to leave comments, you need to log in
function c($a, $b, $numbers) {
foreach ($numbers as $key => $value) {
if ($b === $key && $a % $value == 0) {
//
}
}
}
$a = 1;
$b = 0;
c($a, $b, [7, 3, 2]);
$a++;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question