Get the sum of all digits in a numeric string
php, string, sum
Solution
array_sum(str_split($number));
This assumes the number is positive (or, more accurately, that the conversion of `$number` into a string generates only digits).
Problem
How do I find the sum of all the digits in a number in PHP?