Calculate percentage of up votes
- by MakuraYami
I have searched this site and Google and even though the idea is pretty simple I can't figure it out.
I need to (like seen on YouTube) calculate the % of up-votes based on the amount up-votes and down-votes.
I have two vars, $upvotes and $downvotes now i need to calculate $ratio
For example
$upvotes = 3;
$downvotes = 1;
The ratio here needs to be 75 (%)
If you have
$upvotes = 0;
$downvotes = 100;
It needs to be 0 (%)
How do I calculate the percentage (in PHP)?