i have been trying to figure out how to work out the percentage of users alive on my website/game out of 100% and after that i would need to find the percentage of players dead, i have already cllected the data to show how many of each and that works fine, all i need is to format it into a percentage to go next to the totals.
thanks in advance 🙂
echo "Percent alive: " . round($numberAlive / $totalUsers * 100) . "%";
If you want decimal points, use the 2nd parameter to round() for how many:
echo "Percent alive: " . round($numberAlive / $totalUsers * 100, 2) . "%";
thanks alot, it works perfectly now. and thank you for the very quick reply, i looked at how i had coded it and found the problem after you had posted that, as i read yours and realised i had missed something out. thanks again 🙂