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

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

WBOY
Release: 2016-06-13 13:22:25
Original
1136 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template