Scenario: 1 team attacks the other both have thugs,bodyguards(bgs) and hitmen. Attacking: hitmen>thugs>bgs Defending: hitmen>bgs>thugs So what i need is a function in Php which takes the number in each of the 6 units as inputs and returns values of the number of guys dead in each of the 6 units. Need to be able to set the ratio of strengths too like how much stonger or weaker each unit is with respect to attacking thugs. eg: if i pass a_hitman=100 , a_thugs=100, a_bgs=100, d_hitman=100 , d_thugs=100, d_bgs=100 i get a_hkilled=10 , a_tkilled=20 , a_bkilled=30 , d_hkilled=10 , d_tkilled=30, d_bkilled=20 you can set the ratios as variables which i can change. Please let me know how this can be achieved