I'm creating a clone of "Fanduel". If you are unaware of what it is, let me explain. It is a Daily Fantasy Contest that allows you to draft players from sports such as NFL, MLB, NHL, etc. You create a fantasy team that you enter into contests for cash prizes.
What I'm having trouble with is calculating the prizes. As of now I have it to where only the top 3 winners get paid. For example, 20 people enter a contest and only the 1st, 2nd, and 3rd place entries win a prize. The issue I'm having is that I want to offer a wider range of winners, I would like to calculate prizes in the thousands for large tournaments.
I want to avoid having to enter in thousands of statements in order to achieve this. As you can see below I provided you with the code that I have come up with for the top 3 winners. I'm relatively new to coding and I'm having trouble finding information on this subject. I always refer to Stack Overflow because the advice that you provide is always on point. I haven't come across this subject here either so I apologize if this question has been answered already.
public static function calculatePrizes()
{
$type = $_POST['type'];
$structure = $_POST['structure'];
$size = $_POST['size'];
$entryFee = $_POST['entry_fee'];
$prizes = self::$pools->calculatePrizes($type , $structure, $size, $entryFee);
$result = '<table style="width:100%">'
. '<tr><td style="text-align:left">Pos</td><td style="text-align:right">Prize</td></tr>';
$count = 0;
foreach($prizes as $prize)
{
$count++;
$place = null;
switch ($count)
{
case 1:
$place = '1st';
break;
case 2:
$place = '2nd';
break;
case 3:
$place = '3rd';
break;
}
$result .= '<tr><td style="text-align:left">'.$place.'</td><td style="text-align:right">$'.$prize.'</td></tr>';
}
$result .= '</table>';
exit($result);
}