This is the array which I am getting after selecting sum(amounts) for each products group by date. when the dates did not having correspondent amount it is displaying as empty.I need to display it as zero.
Array
(
[2019-05-16] => Array
(
[0] => 499
)
[2019-05-17] => Array
(
[0] => 1998
)
[2019-05-18] => Array
(
[0] => 195
)
[2019-05-19] => Array
(
[0] => 1194
[1] => 999
)
)
But output should like this,
Is there any way to make empty values as 0
Array
(
[2019-05-16] => Array
(
[0] => 499
[1] => 0
)
[2019-05-17] => Array
(
[0] => 1998
[1] => 0
)
[2019-05-18] => Array
(
[0] => 195
[1] => 0
)
[2019-05-19] => Array
(
[0] => 1194
[1] => 999
)
)
This is the script
foreach ($productid as $itemid) {
$query1 = "select date, SUM(amount) as amount from app_product_details where date between '2019-05-14 00:00:00' and '2019-05-20 23:59:59' and appid = $itemid group by date";
$getquery1 = mysqli_query($conn,$query1);
while($getcount1 = mysqli_fetch_assoc($getquery1))
{
$grset1[] = $getcount1;
}
}
foreach($grset1 as $r){
$dates1[$r['date']][] = $r['amount'];
}
Please help me to reach to the output.