Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
看来我的 array_sum 函数加起来不正确。结果是“0”,这似乎表明没有添加任何项目。
$a = array(); foreach ($ct->data as $key => $value) { $a[$ct->data[$key][3]]; } $totalAmount = array_sum($a);
您实际上并没有将任何内容放入数组中,您只是在数组中设置一个值,将值中所需的值提供给键并将值保留为空。尝试$a[] = $ct->data[$key][3];
$a[] = $ct->data[$key][3];