code: public static function CUMPRINC($rate, $nper, $pv, $start, $end, $type = 0)
      {
          $rate = Functions::flattenSingleValue($rate);
          $nper = (int) Functions::flattenSingleValue($nper);
          $pv = Functions::flattenSingleValue($pv);
          $start = (int) Functions::flattenSingleValue($start);
          $end = (int) Functions::flattenSingleValue($end);
          $type = (int) Functions::flattenSingleValue($type);
  
          // Validate parameters
          if ($type != 0 && $type != 1) {
              return Functions::NAN();
          }
          if ($start < 1 || $start > $end) {
              return Functions::VALUE();
          }
  
          // Calculate
          $principal = 0;
          for ($per = $start; $per <= $end; ++$per) {
              $principal += self::PPMT($rate, $per, $nper, $pv, 0, $type);
          }
  
          return $principal;
      }
docs: CUMPRINC.
  
  Returns the cumulative principal paid on a loan between the start and end periods.
  
  Excel Function:
  CUMPRINC(rate,nper,pv,start,end[,type])
  
  @category Financial Functions
  
  @param float $rate The Interest rate
  @param int $nper The total number of payment periods
  @param float $pv Present Value
  @param int $start The first period in the calculation.
  Payment periods are numbered beginning with 1.
  @param int $end the last period in the calculation
  @param int $type A number 0 or 1 and indicates when payments are due:
  0 or omitted    At the end of the period.
  1                At the beginning of the period.
  
  @return float