i have a array result like the below. it show every payment on each day but i want to add the all the payment in of a day in only one row and the date in one col how can i do that ? thanks
Array ( [cols] => 2017-09-10 [rows] => 1311.45 ) [1] => Array ( [cols] => 2017-09-10 [rows] => 1311.45 ) [2] => Array ( [cols] => 2017-09-10 [rows] => 175000.00 )
my code look like this
foreach($Todaysales as $d)
{
$data[] = ['cols' => date("Y-m-d", strtotime($d['sale_time'])),'rows' => $d['payment_amount']];
}
My desired output is
[[cols]=> 2017-09-10 [rows]=> sum(2017-09-10's sales)]
edited code
$data=Array
(
[2017-09-10] => 178934.35
[2017-09-09] => 700000
[2017-09-07] => 194432.25
[2017-09-06] => 183252.9
[2017-09-03] => 1311.45
[2017-09-02] => 1186.55
[2017-08-30] => 204660.3
[2017-08-29] => 290486.45
[2017-08-28] => 2400
[2017-08-27] => 600.00
[2017-08-26] => 840.00
[2017-08-16] => 600.00
)
to this format after json encoding
[{"cols":"2017-09-02 ","rows":"1186.55"},{"cols":"2017-09-03","rows":"1311.45"}