array(4) {
[0]=>
array(15) {
["id"]=>
string(3) "171"
["order_id"]=>
string(3) "169"
["goods_id"]=>
string(2) "30"
["buyer_id"]=>
string(3) "504"
["store_id"]=>
string(3) "503"
["source"]=>
string(1) "1"
["goods_name"]=>
string(12) "大家都好"
["goods_price"]=>
string(5) "11.00"
["goods_num"]=>
string(1) "2"
["goods_image"]=>
string(37) "http://localhost:80/Public/goodbg.png"
["goods_attr"]=>
array(1) {
[0]=>
array(2) {
["title"]=>
string(6) "啊啊"
["content"]=>
string(6) "哈哈"
}
}
["status"]=>
string(1) "2"
["shopname"]=>
string(30) "孔啦啊啊啊啊啊啊啊啊"
["_source"]=>
string(10) "满e小铺"
["_status"]=>
string(9) "待发货"
}
[1]=>
array(15) {
["id"]=>
string(3) "173"
["order_id"]=>
string(3) "169"
["goods_id"]=>
string(2) "34"
["buyer_id"]=>
string(3) "504"
["store_id"]=>
string(2) "12"
["source"]=>
string(1) "3"
["goods_name"]=>
string(12) "水晶葡萄"
["goods_price"]=>
string(4) "6.00"
["goods_num"]=>
string(1) "2"
["goods_image"]=>
string(61) "http://localhost:80/Public/uploads_goods/1467681791890220.jpg"
["goods_attr"]=>
NULL
["status"]=>
string(1) "2"
["shopname"]=>
string(12) "康师傅的"
["_source"]=>
string(9) "南北货"
["_status"]=>
string(9) "待发货"
}
[2]=>
array(15) {
["id"]=>
string(3) "170"
["order_id"]=>
string(3) "168"
["goods_id"]=>
string(2) "30"
["buyer_id"]=>
string(3) "504"
["store_id"]=>
string(3) "503"
["source"]=>
string(1) "1"
["goods_name"]=>
string(12) "大家都好"
["goods_price"]=>
string(5) "10.00"
["goods_num"]=>
string(1) "2"
["goods_image"]=>
string(37) "http://localhost:80/Public/goodbg.png"
["goods_attr"]=>
array(1) {
[0]=>
array(2) {
["title"]=>
string(6) "啊啊"
["content"]=>
string(6) "哈哈"
}
}
["status"]=>
string(1) "2"
["shopname"]=>
string(30) "孔啦啊啊啊啊啊啊啊啊"
["_source"]=>
string(10) "满e小铺"
["_status"]=>
string(9) "待发货"
}
[3]=>
array(15) {
["id"]=>
string(3) "172"
["order_id"]=>
string(3) "168"
["goods_id"]=>
string(2) "20"
["buyer_id"]=>
string(3) "504"
["store_id"]=>
string(3) "595"
["source"]=>
string(1) "2"
["goods_name"]=>
string(24) "这是一件测试商品"
["goods_price"]=>
string(5) "20.00"
["goods_num"]=>
string(1) "1"
["goods_image"]=>
string(66) "http://localhost:80/Public/upload/goods_two/201704241325435913.jpg"
["goods_attr"]=>
NULL
["status"]=>
string(1) "2"
["shopname"]=>
string(4) "凯2"
["_source"]=>
string(6) "贰货"
["_status"]=>
string(9) "待发货"
}
}
要拼装的样子
array(4) {
[0]=>
array(15) {
["id"]=>
string(3) "171"
["order_id"]=>
string(3) "169"
["buyer_id"]=>
string(3) "504"
['content']=>
[0]=>
array(){
["goods_id"]=>
string(2) "30"
["store_id"]=>
string(3) "503"
["source"]=>
string(1) "1"
["goods_name"]=>
string(12) "大家都好"
["goods_price"]=>
string(5) "11.00"
["goods_num"]=>
string(1) "2"
["goods_image"]=>
string(37) "http://localhost:80/Public/goodbg.png"
["goods_attr"]=>
array(1) {
[0]=>
array(2) {
["title"]=>
string(6) "啊啊"
["content"]=>
string(6) "哈哈"
}
}
["status"]=>
string(1) "2"
["shopname"]=>
string(30) "孔啦啊啊啊啊啊啊啊啊"
["_source"]=>
string(10) "满e小铺"
["_status"]=>
string(9) "待发货"
}
[1]=>
array(){
["goods_id"]=>
string(2) "34"
["store_id"]=>
string(2) "12"
["source"]=>
string(1) "3"
["goods_name"]=>
string(12) "水晶葡萄"
["goods_price"]=>
string(4) "6.00"
["goods_num"]=>
string(1) "2"
["goods_image"]=>
string(61) "http://localhost:80/Public/uploads_goods/1467681791890220.jpg"
["goods_attr"]=>
NULL
["status"]=>
string(1) "2"
["shopname"]=>
string(12) "康师傅的"
["_source"]=>
string(9) "南北货"
["_status"]=>
string(9) "待发货"
}
}
}
大概就是这个样子吧
//$arr 转换前的数组
$arr = array('0'=>array('id'=>'171','goodsid'=>'1'),'1'=>array('id'=>'187','goodsid'=>'2'));
//转换后的数组
$result=array();
foreach($arr as $key => $val){
if($key==0){
$result['id'] = $val['id'];
}
$result'content' = $val;
}
var_dump($result);