Jump to content

simple math


dreamwest
 Share

Recommended Posts

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}%";

?>

Link to comment
Share on other sites

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}%";

?>

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.