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