# Financial math

## Recommended Posts

Im trying to get a monthly repayment for a loan but a \$250,000 loan gives repayments of \$136,250 per month

```function _clean_number(\$input){
return (float) preg_replace('/[^0-9.]/', '', \$input);
}

\$id = 7.3; //interest rate
\$amount = 250000; // amount of loan
\$time = 30; //time in years

\$month_term  = \$time * 12;
\$month_rate = \$id / 12;
\$power = -(\$month_term);
\$denom = pow((1 + \$month_rate), \$power);
\$amount = _clean_number(\$amount);

echo number_format(\$amount * (\$month_rate / (1 - \$denom)));
```

##### Share on other sites

i have no solution yet, but for that money you may call me employee

##### Share on other sites

Found the prob, i still needed to divide the int rate to a monthly amount:

```function _clean_number(\$input){
return (float) preg_replace('/[^0-9.]/', '', \$input);
}

\$id = 7.3; //interest rate
\$amount = 250000; // amount of loan
\$time = 30; //time in years

\$month_term  = \$time * 12;
\$month_rate = (\$id / 100) / 12;
\$power = -(\$month_term);
\$denom = pow((1 + \$month_rate), \$power);
\$amount = _clean_number(\$amount);

echo number_format(\$amount * (\$month_rate / (1 - \$denom)));
```

##### Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

## Join the conversation

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.