php sum of digits

26

<?php
   $num=123;
   $sum=0;
   while($num>0)
   {
     $sum=$sum+$num%10;
     $num/=10
   }
    echo"sum of digit 123 is $sum";
?>

Comments

Submit
0 Comments