$series = array();
while($row = mysql_fetch_assoc($result)) {
$series[$row["data_id"]][] = $row;
}
print_r
a on的输出$series
为两个示例系列:
大批 (
[1] => 数组 ( [0] => 数组 ( [id] => 1 [data_id] => 1 [time_id] => 1 [data] => 1 ) [1] => 数组 ( [id] = > 2 [data_id] => 1 [time_id] => 2 [data] => 3) )
[2] => 数组 ( [0] => 数组 ( [id] => 6 [data_id] => 2 [time_id] => 1 [data] => 7 ) [1] => 数组 ( [id] = > 7 [data_id] => 2 [time_id] => 2 [data] => 4 ) )
我的问题:如何取消设置多维数组,使其仅包含[data]而不包含其他键?我仍然想$series
包含[1]
,[2]
但我不希望各自的子数组包含除[data]
.
事实上,由于我正在减少子数组以包含一个键,我真的很想完全摆脱子数组,以便我有两个数组:
$series[1] = array(1,3) 和 $series[2] = array(7,4)