有一个一维数组,想把它变成m*n形式的二位数组,
$arr = array(....); // 一维数组 $m = ceil(count($arr)/n); $array = array(); for ($i = 0, $j = 0; $i < $m; $i++) { for ($k = 0; $k < n; $k++) { $temp = $arr[$j++]; if($temp) $array[$i][$k] = $temp; } }
原文地址:http://www.cnblogs.com/justcodeit/p/3848339.html