在PHP中查找数字的倍数

dot*_*tty 27 php division modulus

我想在PHP中找到所有多个数字.

我正在使用这样的东西

if($count != 20 )
Run Code Online (Sandbox Code Playgroud)

计算如果$count不等于20.

但我也需要这个脚本来检查是否$count不等于20,40,60,80,100,120,140,​​160等.

有任何想法吗?我想我需要使用模数符号(%),但我不知道.

ric*_*age 21

if ($count % 20 != 0)
{
  // $count is not a multiple of 20
}
Run Code Online (Sandbox Code Playgroud)


mar*_*oda 7

如果您不希望排除零:

if ($count % 20 != 0 || $count == 0)
Run Code Online (Sandbox Code Playgroud)


Kla*_*sen 5

你可以这样做:

if($count % 20 != 0)
Run Code Online (Sandbox Code Playgroud)