Write a PHP Program to Print Sum of Digits.

Sum of Digit Numbers Using PHP Program, How to Sum of Digit by PHP, Print Sum of Digits Number in PHP Program

 

<?php 
$num = 20202021; 
$sum=0; $rem=0; 
for ($i =0; $i<=strlen($num);$i++) 
{ 
$rem=$num%10; 
$sum = $sum + $rem; 
$num=$num/10; 
} 
echo "Sum of digits 20202021 is $sum"; 
?>