ismail - 9 months ago 53

PHP Question

I want to find the coefficients in the loop and add the text.

This coefficient may change. For example: 10, 5, 3 ...

I would like the system to find these coefficients and add text according to the coefficient I set

`$coefficient=10;`

$start=100;

$end=200;

for($i=$start;$i<$end;$i++){

echo $i.'<br>';

}

example;

110 .. text, 120...text, 130...text

or

$coefficient=5; 105...text, 110...text, 115...text

I want to find coefficients and add text

Answer Source

Simple modulus math.

```
$coefficient=10;
$start=100;
$end=200;
for($i=$start;$i<$end;$i++){
if($i % $coefficient == 0) // if (i / coefficient) has a remainder of 0
{
echo $i . "...text";
}
}
```