看看这样子行不?
<?php
$num = 10;//基数
$add = 5;//增幅
$sdate = "2005-06-01";//开始日期
$ndate = date( "Y-m-d" );//现在的日期//一周以七天算。
$out = $num+$add*floor( ( strtotime( $ndate) - strtotime( $sdate ) ) / (60*60*24*7) );
echo $out; 
?>

解决方案 »

  1.   

    要循环输出的话就把
    floor( ( strtotime( $ndate) - strtotime( $sdate ) ) / (60*60*24*7) )作为终点就可以了。如:
    $w = floor( ( strtotime( $ndate) - strtotime( $sdate ) ) / (60*60*24*7) );
    for( $i = 0; $i < $w; $i++ ) {
      echo $out = $num + $add * $i;
    }
      

  2.   

    我现在是这样的,以当前日期字段($gtrw[sub])值为基数, 若我以2006-03-20到2006-03-26这7天的字段($gtrw[sub])值为基数递增,该怎么做?$times = floor( ( strtotime( $statfortime) - strtotime( "2006-03-27" ) ) / (60*60*24*7) );
    $temp_sub = $gtrw[sub] ;for( $i = 1; $i <= $times+1; $i++ ) {      $flat =( strtotime( $statfortime) - strtotime( "2006-03-27" ) ) / (60*60*24*7) ;

    if(is_int( $flat)){
    $gtrw_sub = sprintf("%.00f",$temp_sub);
    } else {
    $gtrw_sub = sprintf("%.00f",$temp_sub + $i);
    }
       
    }