且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取PHP中的数字总和

更新时间:2023-02-10 19:47:18

array_sum(str_split($number));

这假定数字为正(或更准确地说,将$number转换为字符串仅生成数字).

This assumes the number is positive (or, more accurately, that the conversion of $number into a string generates only digits).