Im fetching rows out of a MySQL database. Each row contains a date and an amount (USD). Some of the dates are identical. I've been trying for hours to merge the amount of those rows with identical dates.
I have tried array_merge as well as serveral if-statements, foreach as well as while.
while($row2 = mysqli_fetch_array($result3)) {
array_push($mergeDuplicateDate,
array(
$row2[1], //date
$row2[2] //amount
)
);
};
If the output looks like:
06-25-2019, $5
06-25-2019, $10
06-26-2019, $2
06-26-2019, $1
I want it be summarized like:
06-25-2019, $15
06-26-2019, $3
I know it can't be that hard to do with PHP but I'm not super expirienced at programming. Thus far I could google up any problem that I came across. This time I just can't seem to find an answer. I really don't even know where to start solving this issue.
Thanks in advance to whoever breaks this down to me!