CancelImage Upload

PHP Maths: Calculating the remainder of a division

When working with divisions the remainder is often required. This is often important for subsequent calculations, such as the conversion from seconds into days, minutes and hours.

Here then is how you can establish the remainders of a calculation. Simply place a percentage sign between the two numbers that are to be divided, and which you want to find the remainder off:

<?php

echo "Remainder of 20 divided by 8 = <b>".(20 % 8)."</b><br><br>";

echo "Remainder of 190 divided by 13 = <b>".(190 % 13)."</b><br><br>";

echo "Remainder of 12342321 divided by 1323 = <b>".(12342321 % 1323)."</b><br><br>";

?>


The result:

Remainder of 20 divided by 8 = 4

Remainder of 190 divided by 13 = 8

Remainder of 12342321 divided by 1323 = 54


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com