昨天 GOOCAO搞活动 报名可获得免费上机 把报名的系统完成后需要对积分和上机时间进行计算;写了个function 收藏以后可能用的到 /* * * 积分 * 表:userbonus * */ $ChannelIntegralArr = array ( ' threads ' => 4 , ' comments ' => 4 ); function IntagralConsersionTime( $Integral , $disinfo = '' ){ $AccordTime = 30 ; $result = $Integral - $AccordTime ; if ( $result > 0 ){ $OnlineTime = 1 ; for ( $i = 1 ; $i <= $result ; $i ++ ){ if ( $result - $AccordTime < 0 ){ break ; } $result = $result - $AccordTime ; $OnlineTime ++ ; } $infos = " 当前积分:$Integral<br>可换得上机时间:$OnlineTime 小时<br>剩余积分:$result " ; if ( $disinfo == 1 ){ echo $infos ; } else { $infos = ereg_replace ( ' ' , ' ' , $infos ); echo $infos ; } } else { echo " 目前积分无法满足条件,不能换算 " ; }}