I am creating a jackpot website using real money. It is free to play there, but we will take x% of the total jackpot. I am getting the total jackpot out of different rows in the database. It could look like this:
name | depositedValue
------------------------
Player1 | 50$
Player2 | 20$
..
Some code that maybe can help:
$AllDeposits = $jackpot->getBank();
foreach($AllDeposits as $deposit){
echo $deposit->depositedValue;
}
$cutPercentage = 2;
$cut = ????
I'd do it like this:
$AllDeposits = $jackpot->getBank();
$cutPercentage = 2;
$cut = 0;
foreach($AllDeposits as $deposit){
echo $deposit->depositedValue;
$cut += $deposit->depositedValue * ($cutPercentage / 100.0);
}