一个数组中某个键的值相同则把相同的数组组成一个新数组

$cart_goods = cart_goods($flow_type);

array (size=4)
  0 => 
    array (size=20)
      'rec_id' => string '51' (length=2)
      'user_id' => string '266' (length=3)
      'goods_id' => string '952' (length=3)
      'goods_name' => string 'JSYH-JZY(T.R)T301' (length=17)
      'goods_thumb' => string 'images/201505/thumb_img/952_thumb_G_1431775484368.jpg' (length=53)
      'goods_sn' => string 'ECS000952' (length=9)
      'seller_id' => string '31' (length=2)
      'goods_number' => string '1' (length=1)
      'market_price' => string '432.00' (length=6)
      'goods_price' => string '360.00' (length=6)
  1 => 
    array (size=20)
      'rec_id' => string '50' (length=2)
      'user_id' => string '266' (length=3)
      'goods_id' => string '879' (length=3)
      'goods_name' => string 'AUX-B631' (length=8)
      'goods_thumb' => string 'images/201505/thumb_img/879_thumb_G_1430897618430.jpg' (length=53)
      'goods_sn' => string 'ECS000879' (length=9)
      'seller_id' => string '26' (length=2)
      'goods_number' => string '1' (length=1)
      'market_price' => string '0.00' (length=4)
      'goods_price' => string '279.00' (length=6)
  2 => 
    array (size=20)
      'rec_id' => string '49' (length=2)
      'user_id' => string '266' (length=3)
      'goods_id' => string '877' (length=3)
      'goods_name' => string 'AUX-T002' (length=8)
      'goods_thumb' => string 'images/201505/thumb_img/877_thumb_G_1430982176653.jpg' (length=53)
      'goods_sn' => string 'ECS000877' (length=9)
      'seller_id' => string '26' (length=2)
      'goods_number' => string '1' (length=1)
      'market_price' => string '0.00' (length=4)
      'goods_price' => string '845.00' (length=6)


$cart_store_goods = array();
foreach ($cart_goods as $kc => $vc) {
        $cart_store_goods[$vc["seller_id"]][] = $vc; 
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值