Really Simple Maths in PHP

Published on August 17th, 2020.

Just a few little examples of some basic math operations and how to do them in PHP. It's more of a self note for myself rather than anyone else but feel free to refer to it if you find it useful.

I'll probably continue to update this.

Getting percentage of number

In this example, I'm getting 50% of 100000

$price = 100000;
$percentage = 50;

return ($percentage * $price) / 100;

Converting from pounds to penies

In this example I'm converting the number 1000 to 10000 (£1000 to £100.00)

return 1000 * 100;

My picture

Duncan McClean