时间:2010-07-23 18:28:19

标签: php excel

5 个答案:

答案 0 :(得分:7)

答案 1 :(得分:4)

答案 2 :(得分:1)

这是MathPHP库的修改函数。

<?php
/**
 * Future value for a loan or annuity with compound interest.
 *
 * Same as the =FV() function in most spreadsheet software.
 *
 * The basic future-value formula derivation:
 * https://en.wikipedia.org/wiki/Future_value
 *
 *                   PMT*((1+r)ᴺ - 1)
 * FV = -PV*(1+r)ᴺ - ----------------
 *                          r
 *
 * The (1+r*when) factor adjusts the payment to the beginning or end
 * of the period. In the common case of a payment at the end of a period,
 * the factor is 1 and reduces to the formula above. Setting when=1 computes
 * an "annuity due" with an immediate payment.
 *
 * Examples:
 * The future value in 5 years on a 30-year fixed mortgage note of $265000
 * at 3.5% interest paid at the end of every month. This is how much loan
 * principle would be outstanding:
 *   fv(0.035/12, 5*12, 1189.97, -265000, false)
 *
 * The present_value is negative indicating money borrowed for the mortgage,
 * whereas payment is positive, indicating money that will be paid to the
 * mortgage.
 *
 * @param float $rate
 * @param int $periods
 * @param float $payment
 * @param float $present_value
 * @param bool $beginning adjust the payment to the beginning or end of the period
 *
 * @return float
 */
function fv(float $rate, int $periods, float $payment, float $present_value, bool $beginning = false)
{
    $when = $beginning ? 1 : 0;

    if ($rate == 0) {
        $fv = -($present_value + ($payment * $periods));
        return $fv;
    }

    $initial = 1 + ($rate * $when);
    $compound = pow(1 + $rate, $periods);
    $fv = -(($present_value * $compound) + (($payment * $initial * ($compound - 1)) / $rate));

    return $fv;
}

效果很好,希望能帮到你。

参考:https://github.com/markrogoyski/math-php/blob/master/src/Finance.php

答案 3 :(得分:0)

我遇到了类似的问题,并在this帖子上得到了某人的帮助,我希望其他人也觉得有帮助

答案 4 :(得分:0)

我有同样的问题,发现这个功能非常好。上面这两个对我的需求不起作用......

$ R表示费率,$ n表示期限,$ pmt表示支付金额

  

功能PV($ R,$ n,$ pmt,$ m = 1){

     

$ Z = 1 /(1 +($ R / $ m));

     

返回($ pmt * $ Z *(1 - pow($ Z,$ n)))/(1 - $ Z);

     

}

echo PV(0,00333333, 180, 1221);

不要忘记,如果你想知道,如果你以每年1221欧元的价格每年支付4%的费用,15年之后会得到多少,你将不得不按12的比率划分,放了180个月。