How do I find the sum of all the digits in a number in PHP?
Artefactos method is obviously unbeatable, but here an version how one could do it "manually":
$number = 1234567890;
$sum = 0;
do {
$sum += $number % 10;
}
while ($number = (int) $number / 10);
This is actually faster than Artefactos method (at least for 1234567890), because it saves two function calls.