PHP面试题

面试题 001:

两个数组
$arr_1 = [
    ['goods_id'=>100,'goods_name'=>'商品a'],
    ['goods_id'=>101,'goods_name'=>'商品b'],
    ['goods_id'=>102,'goods_name'=>'商品c'],
    ['goods_id'=>103,'goods_name'=>'商品d'],
    ['goods_id'=>104,'goods_name'=>'商品e'],

];

$arr_2 = [
    ['goods_id'=>100,'date'=>'2018-07-11'],
    ['goods_id'=>103,'date'=>'2018-07-10'],
    ['goods_id'=>104,'date'=>'2018-07-11'],
    ['goods_id'=>105,'date'=>'2018-07-09'],
];


需求: 把数组组合成,如下
[
    ['goods_id'=>100,'goods_name'=>'商品a','date'=>'2018-07-11'],
    ['goods_id'=>101,'goods_name'=>'商品b'],
    ['goods_id'=>102,'goods_name'=>'商品c'],
    ['goods_id'=>103,'goods_name'=>'商品d','date'=>'2018-07-10'],
    ['goods_id'=>104,'goods_name'=>'商品e','date'=>'2018-07-11'],
]


要求不能使用两层循环,效率低

答案在另一篇



你可能感兴趣的:(php面试题,PHP,php面试题)