Hello Guys..
I am looking for a script or method that will pick an item from a list randomly.. But with each item having a certain "chance" of being chosen..
For example I want to pick one of those two (Cat or Dog) where Dog has a 70% chance of being chosen and Cat has a 30% chance.
I will need to repeat this method many many times in my program so please try to give me a method that is maximized and causes minimum load.
rand(1,10) And then see if it's 1,2,3 or 4,5,6,7,8,9,10.
how about making a random number between 1 and 100, which is the percentage...
if (percentage) < 30 cat else dog
also check out using mt_rand insted of rand, check out the manual 🙂
best regards Simon