我的第一个数组是
Array
(
[19] => Array
(
[entity_id] => 19
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => Escape
[has_options] => 1
[required_options] => 0
[created_at] => 2014-02-27 07:33:53
[updated_at] => 2014-03-06 07:29:49
[category_id] => 181
[pgender] => male
[name] => Escape
)
[32] => Array
(
[entity_id] => 32
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => Laundry Service
[has_options] => 1
[required_options] => 0
[created_at] => 2014-02-27 19:41:29
[updated_at] => 2014-03-06 11:02:35
[category_id] => 181
[pgender] => both
[name] => Laundry Service
)
)
第二个数组是:
Array
(
[20] => Array
(
[entity_id] => 20
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => Escape
[has_options] => 1
[required_options] => 0
[created_at] => 2014-02-27 07:33:53
[updated_at] => 2014-03-06 07:29:49
[category_id] => 181
[pgender] => male
[name] => Escape name
)
[32] => Array
(
[entity_id] => 32
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => Laundry Service
[has_options] => 1
[required_options] => 0
[created_at] => 2014-02-27 19:41:29
[updated_at] => 2014-03-06 11:02:35
[category_id] => 181
[pgender] => both
[name] => Laundry Service
)
)
我想通过唯一键合并数组:
Array
(
[1] => Array
(
[entity_id] => 19
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => Escape
[has_options] => 1
[required_options] => 0
[created_at] => 2014-02-27 07:33:53
[updated_at] => 2014-03-06 07:29:49
[category_id] => 181
[pgender] => male
[name] => Escape
)
[2] => Array
(
[entity_id] => 32
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => Laundry Service
[has_options] => 1
[required_options] => 0
[created_at] => 2014-02-27 19:41:29
[updated_at] => 2014-03-06 11:02:35
[category_id] => 181
[pgender] => both
[name] => Laundry Service
)
[3] => Array
(
[entity_id] => 20
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => Escape
[has_options] => 1
[required_options] => 0
[created_at] => 2014-02-27 07:33:53
[updated_at] => 2014-03-06 07:29:49
[category_id] => 181
[pgender] => male
[name] => Escape name
)
)
答案 0 :(得分:1)
只需使用array_merge
- http://bd1.php.net/array_merge
$res = array_merge($arr1, $arr2);
它会保留$arr1
中重复的$arr2
密钥。
答案 1 :(得分:0)
数组合并然后使用数组值
array_values(array_merge($array1 , $array1));