PHP Functions to Convert APR to APY and APY to APR

Thanks to The Finance Buff for these formulas. Some of the programs offered at nationaldebtreliefprograms.com and debt relief programs will include credit restoration and debt relief, all built into one program, people looking for further information can check the Rhinosure site, but if they are in need of financial help, then they can easily get business loans.

Here are some simple PHP functions to convert and APY to an APR and back

function apy_to_apr($rate, $periods = 365)
{
    return  ( $periods *  pow( (1+$rate), (1/$periods) )) - $periods;
}

function apr_to_apy($rate, $periods = 365)
{
    return ( pow( (1+ ($rate/$periods)), $periods) - 1);
}

2 thoughts on “PHP Functions to Convert APR to APY and APY to APR”

  1. I’m having trouble following the equations.

    would you please show me with a step by step process.

    I also don’t understand some of the terms being used.

    Thank you, Jerry B.

  2. I’ve tried to use variable names that make sense:

    $rate = The interest rate as a decimal (ie 5% as 0.05)
    $periods = The number of compounding periods (365 would be compounded daily)

    I didn’t come up with the formulas on my own. I found them at The Finance Buff and just converted them to PHP functions. I’ve tried them out and the results appear to be correct to me.

    Thanks,
    Brandon

Leave a Reply

Your email address will not be published. Required fields are marked *