Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

How can I use php to calculate how long it will take to pay off a credit card debt using a minimum payment option.

Here are the variables:

Credit Card Balance: $ccb

APR: $apr

Minimum Payment percentage of balance: $mmp

Determine:

Number of months to pay off: $mos

Amount Paid: $amt

Credit cards offer a minimum payment option, typically 3% of the balance due. If you make only the minimum payment and your balance is say $20000 how long will it take to pay off the entire balance and how much money will have been spent to pay off the balance?

I need the formula to be written in PHP.

Here are the variables:

Credit Card Balance: $ccb

APR: $apr

Minimum Payment percentage of balance: $mmp

Determine:

Number of months to pay off: $mos

Amount Paid: $amt

Credit cards offer a minimum payment option, typically 3% of the balance due. If you make only the minimum payment and your balance is say $20000 how long will it take to pay off the entire balance and how much money will have been spent to pay off the balance?

I need the formula to be written in PHP.

1 Solution

@Aburr, thank you. I will try to take your formula to the php experts.

asume $mm is the minimum of the accpetable minimal payment, e.g. 100 in awking00's comment;

let $mr be the monthly interest rate as $apr/12.0

let $r = (1.0-$mmp)*(1.0+$mr) and this is the acctual rate of your balance decreasing.

then N+1 months is needed to pay off the debt, where

N = floor( log($mm/$ccb)/log($r)), floor(R) is the largest integer that <=R

$mos = N+1

and in the end, an amount of

$amt = $ccb*($mmp*(1.0-$r^(N-1))/

has been paid in total.

let me know if this is not detailed enough.

Tackle projects and never again get stuck behind a technical roadblock.

Join Now
A loop including

$newbalance = $ccb ($ccb*100*$mmp) +$ccb *100/12*$apr

Iterate (putting $newbalance for $ccb) until $newballance = 0

$amt = sum of all terms in ()

Details such as how often interest is charged to the account (monthly, daily,?), how to handle the last iteration, number of payments required in year (not always 12), have to be addressed.