/**
* 1,3,5,8,12 结果要求是2,2,3,4
* 找规律 后面的数减去前一个
**/
public function arrayPendAction(){ $arr = array(1,3,5,8,12); $count = count($arr)-1; foreach($arr as $k=>$val){ if($k < $count) { $new[]= $arr[$k+1]-$arr[$k]; } } }
/**
* 1,3,5,8,12 结果要求是2,2,3,4
* 找规律 后面的数减去前一个
**/
public function arrayPendAction(){ $arr = array(1,3,5,8,12); $count = count($arr)-1; foreach($arr as $k=>$val){ if($k < $count) { $new[]= $arr[$k+1]-$arr[$k]; } } }