How to calculate percentages based on 'weight'? : <p>I would like to calculate/split percentages among an any number of people based on 'weights'.</p>

<p>Weight, in this case, is a modifier about how much does that person weigh in the splitting. We can set these weights before from 1 to 100, and the program should automatically split 100% between the people.</p>

<p>Here is the example what I'd like to achieve:</p>

<pre><code>Person 1 'weight': 100
Person 2 'weight': 10
Person 3 'weight': 100
Person 4 'weight': 100
</code></pre>

<p>And the result I'd need is:</p>

<pre><code>Person 1 : 32.26%
Person 2 : 3.23%
Person 3 : 32.26%
Person 4 : 32.26%
</code></pre>

<p>I know that it has something to do with proportions but can't think of how to calculate this. I'd like to do it inside a Javascript or PHP function.</p>
