It seems that my array_sum function is not adding up correctly. The result is “0” which seems to indicate that none of the items are being added.
$a = array();
foreach ($ct->data as $key => $value) {
$a[$ct->data[$key][3]];
}
$totalAmount = array_sum($a);
You’re not actually putting anything into the array, you’re just setting a value in the array, giving the value you want in the value to the key and leaving the value null. Try
$a[] = $ct->data[$key][3];