日期:2014-05-16 浏览次数:20582 次
$data = array(
20120621 => 360.33,
20120811 => 341.46,
20120911 => 341.46,
20121011 => 341.46,
20121111 => 341.46,
20121211 => 341.46,
20130111 => 342.22,
20130211 => 337.04,
20130311 => 337.04,
20130411 => 337.04,
20130511 => 337.04,
20130611 => 337.04,
20130711 => 337.04,
20130811 => 337.04,
20130911 => 337.04,
20131008 => 334.99,
20131009 => 2224.79,
20131011 => 337.04,
20131014 => 16223.38,
);
<?php
//贷款2万人民币,从2012年06月开始还清,假如2013年10月结清,总利息应该还多少?
//逾期年利率 10.26% ,年利率 6.84%.展期年利率 5.94%
//本科免利息,读研2年算展期(也免利息?) 逾期利息10.26
//假设利息是包含 产生的利息的
//复利:产生的利息作为本金再算利息!
$data = array(
20120621 => 360.33,
20120811 => 341.46,
20120911 => 341.46,
20121011 => 341.46,
20121111 => 341.46,
20121211 => 341.46,
20130111 => 342.22,
20130211 => 337.04,
20130311 => 337.04,
20130411 => 337.04,
20130511 => 337.04,
20130611 => 337.04,
20130711 => 337.04,
20130811 => 337.04,
20130911 => 337.04,
20131008 => 334.99,
20131009 => 2224.79,
20131011 => 337.04,
20131014 => 16223.38,
);
//获取利息率
function getRate($month)
{
$m = substr($month ,0 ,6);
if($m < 201006) return 0; //2006 09入学 2010 06毕业
else if($m < 201206) return 5.94*0.01; //2012 06之前算展期
else return 10.26*0.01; //201206之后算逾期
}
$ttXi = 0;//总利息
$moneyDK = 20000;
$ttLeft = $moneyDK; //贷款20000
$ttBack = 0;
$i = 0;
$monthArr = array_keys($data);
$moneyArr = array_values($data);
echo '<table border="1" cellpadding="0" width="100%">';
while($ttLeft > 0)
{
$money = $moneyArr[$i];
$month = $monthArr[$i];
$ttBack += $money; //累计还款总额
$rate = getRate($month);
$xi = $ttLeft*$rate/12;
$ttXi += $xi;
//$ttLeft += $xi;//假设不需要复利
$ttLeft -= $money; //减去已还款
echo '<tr><td>'.($i+1).'</td>
<td>时间:'.$month.',本月实际还款:'.number_format( $money ).'</td>
&nbs