Sum of Digits

Calculate the sum of all digits in a number.

Code

General
array_sum(str_split((string)abs($num)));

Parameters

Number

Server

More PHP Snippets