Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有更好的方法在 php 中执行此操作 - 我本来是这么认为的,但这就是我能想到的。
$x = 4 $y = 32 while ($y > $x) { $y = $y-$x; }
$y 的最终值是我所追求的。
使用 mod 运算符:
$remainder = $y % $x;
如果你想得到多少,请使用除法并发言:
$total = floor( $y / $x);
所以,使用$y = 35;and $x = 4;,你会得到:
$y = 35;
$x = 4;
$total = 8, $remainder = 3