Divide the two numbers and multiply them by 100 to get a percentage:
$percentage = ($num1 / $num2) * 100; echo $percentage . "%";
Of course, you will need to check that $num1 not 0, something like this: $percentage = ($num1 !== 0 ? ($num1 / $num2) : 0) * 100;
source share