Note: This is not just about summing phone time, phone time needs to calculated seperately through PHP function
I am currently having following code
$i = array(1,2,3,4,5,6,7,8,9,10,11,12);
$j = array();
foreach ($i as $item) {
$month_query_phonetime = $conn->query("SELECT phone_time FROM bigscreen_daily_data WHERE MONTH(work_date) = {$item} AND YEAR(work_date) = YEAR(CURDATE()) AND user_id = 28");
while ($dataitem = $month_query_phonetime->fetch_object()) {
$j[][$item] = point_for_phone_time($dataitem->phone_time);
}
}
print_r($j);
this is giving me result as as follows
Array
(
[0] => Array
(
[1] => 0
)
[1] => Array
(
[1] => 10
)
[2] => Array
(
[2] => 48
)
[3] => Array
(
[2] => 24
)
[4] => Array
(
[3] => 48
)
[4] => Array
(
[3] => 48
)
)
I am trying to get sum of all [1] => value, [2]=> value and etc as one variable and pass it to indual item in $j[][$item] so that it can be used for further processing
i have tried doing
while ($dataitem = $month_query_phonetime->fetch_object()) {
$m = $m + point_for_phone_time($dataitem->phone_time);
}
$j[][$item] = $m;
its giving me values as follows
Array
(
[0] => Array
(
[1] => {value1}
)
[1] => Array
(
[2] => {value1+value2}
)
)
and so in order to get desired results which is correct format to handle this.