I am getting undefined variable as I sum up the total in for loop. I declare using empty string but it is giving me non-numeric value error and I don't know why I am getting this error.
$detail= array(
[0] => Array
(
[id] => 4
[item] => 8
[plant] => 4
[uom] => 1
[t_load] => 1
[rate] => 5
[quantity] => 289
[total] => 6310
)
[1] => Array
(
[id] => 5
[item] => 13
[plant] => 6
[uom] => 1
[t_load] => 1
[rate] => 16
[quantity] => 300
[total] => 6310
)
)
<?php foreach($detail as $details):?>
<tr>
<td><?php echo $details['plant']; ?></td>
<td><?php echo $details['item']; ?></td>
<td><?php echo $details['t_load']; ?></td>
<td><?php echo $details['quantity']; ?></td>
<td><?php echo $details['rate']; ?></td>
<td><?php echo $details['total']; ?></td>
</tr><?php
$grandTotal += $details['total'];
endforeach; ?>