How do I find the sum of all the digits in a number in PHP?
Here's the code.. Please try this
1) { $temp=$temp/10; $d++; } echo "Digits Are : $d "; for (;$num>1;) { $d=$num%10; $num=$num/10; $sum=$sum+$d; } echo "Sum of Digits is : $sum"; ?>