Skip to content

Instantly share code, notes, and snippets.

@NEbere NEbere/sum.php
Created Feb 11, 2016

What would you like to do?
Sum of the integers in a string
function digitSum($n) {
$array = str_split($n);
$sum = array_sum($array);
print $sum;
//calling the function
//returns 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.