<?php /* *多维数组去重,根据变量值组合商品属性。 *数组字段:dim维度,dimName维度名称,sku(value商品属性,shopid商品id) *假若,变量$shopid = 101;为当前商品id,则希望组合为 *1、所有的维度去重 *2、保留当前商品的颜色属性,就是说樱语粉的商品id是101,另外几个颜色任意保留其中一个。 * 下面两个维度,保留颜色是樱语粉的属性。 ***----------------------------------*** **颜色 : 樱语粉(101) 珠光白 魅海蓝 流光金 **版本 : 64GB(101) 32GB(105) **套装 : 官方标配(101) 特别版(102) ***----------------------------------*** *求大神帮忙解答!!! */ $arr = array( '1' => array( 'dim' => 1, 'dimName' => '颜色', 'sku' => array( '0' => Array('value' => '樱语粉','shopid' => 101), '1' => Array('value' => '樱语粉','shopid' => 102), '2' => Array('value' => '珠光白','shopid' => 103), '3' => Array('value' => '魅海蓝','shopid' => 104), '4' => Array('value' => '樱语粉','shopid' => 105), '5' => Array('value' => '流光金','shopid' => 106), '6' => Array('value' => '流光金','shopid' => 107), '7' => Array('value' => '魅海蓝','shopid' => 108) ) ), '2' => Array( 'dim' => 2, 'dimName' => '版本', 'sku' => Array( '0' => Array('value' => '64GB','shopid' => 101), '1' => Array('value' => '64GB','shopid' => 102), '2' => Array('value' => '64GB','shopid' => 103), '3' => Array('value' => '32GB','shopid' => 104), '4' => Array('value' => '32GB','shopid' => 105), '5' => Array('value' => '32GB','shopid' => 106), '6' => Array('value' => '64GB','shopid' => 107), '7' => Array('value' => '64GB','shopid' => 108) ) ), '3' => Array( 'dim' => 3, 'dimName' => '套装', 'sku' => Array( '0' => Array('value' => '官方标配','shopid' => 101), '1' => Array('value' => '特别版','shopid' => 102), '2' => Array('value' => '官方标配','shopid' => 103), '3' => Array('value' => '官方标配','shopid' => 104), '4' => Array('value' => '官方标配','shopid' => 105), '5' => Array('value' => '官方标配','shopid' => 106), '6' => Array('value' => '官方标配','shopid' => 107), '7' => Array('value' => '官方标配','shopid' => 108) ) ) );