Can you help me to explain this code : <pre><code>&lt;?php

$val = 999;
$sum = 0;
while($val){
   $sum += $val % 10; 
   $val = $val / 10; 
} 
echo $sum;

?&gt;
</code></pre>

<p>Please help me to explain above code,
Why $sum is sum all digits of $val?</p>
