要獲取兩個(gè)數(shù)的余數(shù),可以使用PHP內(nèi)置的modulus操作符“%”。以下是一個(gè)示例:
<?php
$dividend = 10;
$divisor = 3;
$remainder = $dividend % $divisor;
echo "The remainder of $dividend divided by $divisor is: $remainder";
?>
運(yùn)行以上代碼會(huì)輸出:
The remainder of 10 divided by 3 is: 1
這樣就可以通過PHP函數(shù)獲取余數(shù)了。