dreamwest Posted March 29, 2012 Share Posted March 29, 2012 Trying to get the percentage of rent for a property in php. Im completely lost .... <?php $purchase = 44000; $rent = 9860; $percent = $purchase * $rent; //this is wrong, it returns 4.3 but should be over 18 echo "Percentage is {$percent}%"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/259926-simple-math/ Share on other sites More sharing options...
abrahamgarcia27 Posted March 29, 2012 Share Posted March 29, 2012 i think this is what your looking for, but i dont know anything about what percentage you want. What this percentage is telling yo is that the rent is 22% percent of the total purchase price. I am not sure if this is what you are looking for <?php $purchase = 44000; $rent = 9860; $percent = round($rent / $purchase * 100, 2); //this is wrong, it returns 4.3 but should be over 18 echo "Percentage is {$percent}%"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/259926-simple-math/#findComment-1332249 Share on other sites More sharing options...
dreamwest Posted March 29, 2012 Author Share Posted March 29, 2012 that's it, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/259926-simple-math/#findComment-1332253 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.