I have a formula that works out how to work out a betting accumulator.
The formula is :
Stake x ( Fractional Odds + 1 ) x ( Fractional Odds + 1 ) etc...
I am looking to write a PHP function that loops through the odds and then returns the value.
I have an array as follows (Contains fractional odds)...
$odds = array(
'8/15',
'11/2',
'13/2',
'7/2'
);
Some example PHP code, That shows how I can do this (without a function)...
$result = 10 * (8/15 + 1) * (11/2 + 1) * (13/2 + 1) * (7/2 + 1);
echo number_format($result,2); // 3,363.75
and my stake is set as '10' for now.
What I need to do is loop through the odds array and multiply them by the brackets and to start with multiply by the Stake so for this is test case is 10.
Can anyone suggest a way to write this? When I do try write in * I keep getting PHP errors.
If the topic is not suitable for the community, Please state and I'll remove.
Thanks