[19] => Array
(
[date] => 2015-03-02
[supervisor] => 16
[avg] => 1.50
)
[20] => Array
(
[date] => 2015-03-03
[supervisor] => 16
[avg] => 1.50
)
[21] => Array
(
[date] => 2015-03-04
[supervisor] => 16
[avg] => 1.50
)
[22] => Array
(
[date] => 2015-01-02
[supervisor] => 26
[avg] =>
)
[23] => Array
(
[date] => 2015-01-05
[supervisor] => 26
[avg] =>
)
我有这个数组。我想通过主管将这个单个数组拆分为2个数组
例如,这里只有2个不同的主管(16,26)。我想要两个单独的数组。
喜欢:
数组1:
[20] => Array
(
[date] => 2015-03-03
[supervisor] => 16
[avg] => 1.50
)
[21] => Array
(
[date] => 2015-03-04
[supervisor] => 16
[avg] => 1.50
)
Array 2:
[22] => Array
(
[date] => 2015-01-02
[supervisor] => 26
[avg] =>
)
[23] => Array
(
[date] => 2015-01-05
[supervisor] => 26
[avg] =>
)
请帮帮我。
答案 0 :(得分:0)
您是否尝试在PHP
中执行此操作?
如果是这样..
为主管创建一个新数组
$supervisors = array();
首先循环当前数组
foreach($arr as $key => $value):
$supervisor = $value['supervisor'];
//Add more data to the array here
$supervisors[$supervisor] = //Array of info you require
endforeach;