# PHP calculations for golf handicap calculator

Staff member
I have a golf handicap calculator setup in wordpress that displays the results as shown below.
Currently this is calculating a handicap based on all rounds played (the score minus the ACR gives the round differential, this is then added together and dived by rounds played and multiplied by 0.93, giving the result).

But I need it to do something like the following:

If user has played between 3-6 rounds, then only use the lowest differential

If user has played between 7-8 rounds, then only use the lowest 2 differentials

If user has played between 9-10 rounds, then only use the lowest 3 differentials
and so on...

I have each rounds differential stored in a variable called \$results as shown below

Code:
``````// Begin calculations
\$result = \$score - \$acr;         //gives each rounds differential
array_push(\$array,\$result);      //puts all differentials in array
\$num = \$the_query-&gt;found_posts;  //counts number of rounds
\$av = array_sum(\$array) / \$num;  //calculates average differential
\$round = round(\$av) * 0.93;      //this is the final handicap``````

Any ideas on how best to achieve this???

<img src=" " alt="enter image description here">