复杂数组合并的求助~~~~
<?php
//获取了这么一个数据
$arrData=array(
0=>array(
'id'=>1,
'advdate'=>'2015-02-11',
'pid'=>13,
'active'=>0,
'active_num'=>50,
'money'=>200,
),
1=>array(
'id'=>1,
'advdate'=>'2015-02-11',
'pid'=>13,
'active'=>1,
'active_num'=>30,
'money'=>200,
),
2=>array(
'id'=>1,
'advdate'=>'2015-02-11',
'pid'=>13,
'active'=>2,
'active_num'=>40,
'money'=>200,
),
//....多维,后面的id,pid都不一样.
);
//需要组装成如下. 当active=0,对应active0, active=1,对应active1...
$arrRes=array(
array( '
id'=>1,
'advdate'=>'2015-02-11',
'pid'=>13,
'money'=>200,
'active0'=>50,
'active1'=>30,
'active2'=>40,
),
array(
'id'=>2,
....
...
),
);
//请问一下这如何组装啊~~
?>
你要的是這個嗎?
foreach($arrData as $key=>$rows){ $arrData[$key] = $rows; } Closer 发表于 2015-2-12 16:25
你要的是這個嗎?
不是...
有这么一个表 a,字段是:
id,advdate,pid,active,active_num,money
1 ‘时间’ 5 0 30 200
1 ‘时间’ 5 1 40 200
1 ‘时间’ 5 2 50 200
2 ‘时间’ 5 0 60 200
2 ‘时间’ 5 1 70 200
2 ‘时间’ 5 2 80 200
其中:active_num 是active的数量。active有3中类型,分别为active0,active1,active2.
然后还有一个表 b:
需要的是。把a表 的数据insert到b表中,
id,advdate,pid,active0,active1,active2, money
1 ‘时间’ 5 30 40 50 200
1 ‘时间’ 5 60 70 80 200
页:
[1]