Home > Backend Development > PHP Tutorial > 请问PHP算法,二维数组取出一维数组中id相同为几个新的二维数组

请问PHP算法,二维数组取出一维数组中id相同为几个新的二维数组

WBOY
Release: 2016-06-13 12:37:41
Original
997 people have browsed it

请教PHP算法,二维数组取出一维数组中id相同为几个新的二维数组。
小弟刚学PHP不久,遇到了一个问题,请教大侠们,谢谢!

二维数组如下;
$arr = array(
array('id'=>100,'value'=>100),
array('id'=>100,'value'=>130,
array('id'=>100,'value'=>140),
array('id'=>100,'value'=>150),
array('id'=>101,'value'=>1600),
array('id'=>101,'value'=>100),
array('id'=>102,'value'=>100),
array('id'=>102,'value'=>100),
array('id'=>102,'value'=>100),
array('id'=>103,'value'=>100),
array('id'=>103,'value'=>100),
array('id'=>104,'value'=>100),
array('id'=>104,'value'=>100),
array('id'=>104,'value'=>100),
array('id'=>105,'value'=>100)
);


如何拆分成下面5个二维数组:
arr1(
                array('id'=>100,'value'=>100),
array('id'=>100,'value'=>130,
array('id'=>100,'value'=>140),
array('id'=>100,'value'=>150)
);

arr2(
array('id'=>101,'value'=>1600),
array('id'=>101,'value'=>100)
);

arr3(
array('id'=>102,'value'=>100),
array('id'=>102,'value'=>100),
array('id'=>102,'value'=>100)
);

arr4(
array('id'=>103,'value'=>100),
array('id'=>103,'value'=>100)

);

arr5(
array('id'=>104,'value'=>100),
array('id'=>104,'value'=>100),
array('id'=>104,'value'=>100),
array('id'=>105,'value'=>100)
);

arr5(
array('id'=>105,'value'=>100)
);

PHP 二维数组 算法
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