02.05.2017, 09:13
Well, it really depends on the amount of businesses you actually have vs. the amount of max businesses defined in the script.
If you have a max business value of 100, while you only have 15 valid businesses you'll have a chance of waiting a very long time before the randomizer finally hits one of the valid businesses, it can take up to minutes if not hours or days. I would rather grab a random value based on an enum length, so in this case you'll end up like this:
I haven't tested it, but in theory this should work a lot more efficient, once I have the chance to do so I'll do some benchmarking tests comparing your method with mine.
If you have a max business value of 100, while you only have 15 valid businesses you'll have a chance of waiting a very long time before the randomizer finally hits one of the valid businesses, it can take up to minutes if not hours or days. I would rather grab a random value based on an enum length, so in this case you'll end up like this:
PHP код:
new i = random(sizeof(BusinessData));