Home  >  Article  >  Backend Development  >  PHP1维数组转成二维数组的方法

PHP1维数组转成二维数组的方法

WBOY
WBOYOriginal
2016-06-13 10:34:34870browse

PHP一维数组转成二维数组的方法?
PHP一维数组转换成2维数组,每6个一组划分,怎么搞的?
$i=1;
while (list($name,$value)=each($_POST)) {
$j=ceil($i/6);
//$data[$i]=$value;
echo "$i::$j:$name=$value"."
";
array_push($data[$j],$value); //此处不知道怎么实现
$i++;
}
array_push($data[$j],$value); //这个地方怎么写?


------解决方案--------------------
我不知道你原始的数组是什么样的
也不知道希望转换后的数组是什么样的
------解决方案--------------------
$data[$j][] = $value

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn