PHP Calculation - Modulus 10 check digit generation : <p>I got a problem here figuring out how to do this:</p>

<ol>
<li>I got a document no for example <code>5843</code></li>
<li>Starting with the right-most digit, multiply every other digit by 2 and 1 (For example, <code>(3x2)+(4x1)+(8x2)+(5x1)</code> and so on)</li>
<li>For every multiplication that results a number more than 9, add them digits. (For example, from the calculation on (no.2) we will get this :
<code>(6)+(4)+(16)+(5)</code>. So we got a number (16) which is more that 9. We need to add them <code>(1+6=7)</code>. Now the output will be like this : <code>(6)+(4)+(7)+(5)</code>.</li>
<li>Next, we add them <code>(6)+(4)+(7)+(5)=22</code></li>
<li>Now, we <code>divide 22 by 10</code> and get the remainder which is <code>2</code> in this case.</li>
<li>Lastly we minus the remainder with <code>10</code>. </li>
<li>So the last output will be <code>8</code></li>
</ol>

<p>Can you guys guide me on how to do this? Thank you very much !</p>
