I am having an issue with something and I can’t get my head around it.
I have a weight function that chooses a random number from an array depending on the weight given.
So when i have an array like
array('high' => '10', 'medium' => '30', 'low' => '60'); i don’t have any issues.
My problem is that when tickets will be sold out, I need to remove it from the array and then split the rest on 100%.
so for example, if there is no more "high" tickets, my array need to be something like
array('medium' => '33.3', 'low' => '66.7');
How can I code a function that will always return the right amount on 100 depending on what weight is available?
Source: Ask PHP