title: Need help converting PV formula to PHP
body: <p>I need help converting the following excel formula to PHP</p>
  
  <p><code>PV(.0588/12,300,868.0583333)</code></p>
  
  <p>The output I am expecting is <code>136,275.88</code>, but the output that I am getting is <code>590573.166</code>. I have spent hours on it but I can't seem to find the solution.</p>
  
  <p>This is my code</p>
  
  <pre><code>function FV($rate = 0, $nper = 0, $pmt = 0, $pv =0, $type = 0)
  {
  
      // Validate parameters
      if ($type != 0 &amp;&amp; $type != 1) {
          return False;
      }
  
      // Calculate
      if ($rate != 0.0) {
          return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate;
      } else {
          return -$pv - $pmt * $nper;
      }
  } //  function FV()
  echo FV(.0588/12, 300, -868.06);
  </code></pre>
  
  <p>I have gone through the <a href="https://stackoverflow.com/questions/3321228/how-can-i-replicate-the-excel-fv-function-in-php">similar</a> post before but that does not solve.</p>
  
  <p>I have also gone through the PHP <a href="http://www.php.net/manual/en/ref.math.php#50833" rel="nofollow noreferrer">site</a> but that does not help either.</p>