php 两个数组,组合到一起
Array([7]=>Array([Price]=>100[Count]=>2)[11]=>Array([Price]=>68[Count]=>1))Array([0]=...
Array
(
[7] => Array
(
[Price] => 100
[Count] => 2
)
[11] => Array
(
[Price] => 68
[Count] => 1
)
)
Array
(
[0] => Array
(
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/3/4/d/a/thumb_54e05b04e4e1c.jpg
[ItemName] => 蓝玛瑙
[ItemDescription] =>
)
[1] => Array
(
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/d/1/a/f/thumb_54e0609cb71b0.jpg
[ItemName] => 可调大小朱砂双鱼手串
[ItemDescription] =>
)
)
请问如何这两个数组合并成一个数组 数组 $a $b 变成下面C
Array
(
[7] => Array
(
[Price] => 100
[Count] => 2
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/3/4/d/a/thumb_54e05b04e4e1c.jpg
[ItemName] => 蓝玛瑙
[ItemDescription] =>
)
[11] => Array
(
[Price] => 68
[Count] => 1
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/d/1/a/f/thumb_54e0609cb71b0.jpg
[ItemName] => 可调大小朱砂双鱼手串
[ItemDescription] =>
)
) 展开
(
[7] => Array
(
[Price] => 100
[Count] => 2
)
[11] => Array
(
[Price] => 68
[Count] => 1
)
)
Array
(
[0] => Array
(
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/3/4/d/a/thumb_54e05b04e4e1c.jpg
[ItemName] => 蓝玛瑙
[ItemDescription] =>
)
[1] => Array
(
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/d/1/a/f/thumb_54e0609cb71b0.jpg
[ItemName] => 可调大小朱砂双鱼手串
[ItemDescription] =>
)
)
请问如何这两个数组合并成一个数组 数组 $a $b 变成下面C
Array
(
[7] => Array
(
[Price] => 100
[Count] => 2
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/3/4/d/a/thumb_54e05b04e4e1c.jpg
[ItemName] => 蓝玛瑙
[ItemDescription] =>
)
[11] => Array
(
[Price] => 68
[Count] => 1
[ImageUrl] => http://www.baidu.com/uploads/r/roynyj1423816159/d/1/a/f/thumb_54e0609cb71b0.jpg
[ItemName] => 可调大小朱砂双鱼手串
[ItemDescription] =>
)
) 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
展开全部
就是用array_merg来组合数组
$arr1=Array("Price" => 100,"Count" => 2);
$arr2=Array("Price" => 68,"Count" => 1);
$arr3=Array("ImageUrl" => "http://www.baidu.com/uploads/r/roynyj1423816159/3/4/d/a/thumb_54e05b04e4e1c.jpg","ItemName" => "蓝玛瑙","ItemDescription" =>"");
$arr4=Array("ImageUrl" => "http://www.baidu.com/uploads/r/roynyj1423816159/d/1/a/f/thumb_54e0609cb71b0.jpg","ItemName" => "可调大小朱砂双鱼手串","ItemDescription" =>"");
$data1=array_merge($arr1,$arr3);
$data2=array_merge($arr2,$arr4);
$datas=Array("7"=>$data1,"11"=>$data2);
print_r($datas);
$arr1=Array("Price" => 100,"Count" => 2);
$arr2=Array("Price" => 68,"Count" => 1);
$arr3=Array("ImageUrl" => "http://www.baidu.com/uploads/r/roynyj1423816159/3/4/d/a/thumb_54e05b04e4e1c.jpg","ItemName" => "蓝玛瑙","ItemDescription" =>"");
$arr4=Array("ImageUrl" => "http://www.baidu.com/uploads/r/roynyj1423816159/d/1/a/f/thumb_54e0609cb71b0.jpg","ItemName" => "可调大小朱砂双鱼手串","ItemDescription" =>"");
$data1=array_merge($arr1,$arr3);
$data2=array_merge($arr2,$arr4);
$datas=Array("7"=>$data1,"11"=>$data2);
print_r($datas);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
事实上,数组A和数组B中元素很难顺序一致,容易出现价格与商品不对应,故php没有提供这种函数方法
导致这种问题的根本原因还是数据库表没有建得不规范,建议研究下
导致这种问题的根本原因还是数据库表没有建得不规范,建议研究下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
array_merge应该不行了,只能遍历数组来做了~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询