我有2个多维数组。第一个来自数据库(示例值),另一个作为日期间隔(日期更多,可能更大)。我需要生成第三个数组,以填补第一个数组的日期空白,请注意,键“ agent”的值发生了变化。
php5,sqlServer,pdo连接
<?php
$array_sellers = array(
array(
'agent'=>1,
'date' =>'2019-01-01',
'sales' =>2
),
array(
'agent'=>1,
'date' =>'2019-01-02',
'sales' =>4
),
array(
'agent'=>2,
'date' =>'2019-01-03',
'sales' =>1
),
);
$array_dates = array('2019-01-01','2019-01-02','2019-01-03');
//output array
$output = array(
array(
'agent'=>1,
'date' =>'2019-01-01',
'sales' =>2
),
array(
'agent'=>1,
'date' =>'2019-01-02',
'sales' =>4
),
array(
'agent'=>1,
'date' =>'2019-01-03',
'sales' =>0
),
array(
'agent'=>2,
'date' =>'2019-01-01',
'sales' =>0
),
array(
'agent'=>2,
'date' =>'2019-01-02',
'sales' =>0
),
array(
'agent'=>2,
'date' =>'2019-01-03',
'sales' =>1
),
);
?>