mercredi 27 septembre 2017

Write a function in php, which allows to randomly draw an element from a list

I would like to write a function in PHP which allows to randomly draw an element from a list according to defined probabilities.

For example:

For an argument with the input (x = 20, y = 15, z = 35, t = 30), the function should have a 20% chance for x, 15% for y, 35% for z and 30% for t

Any ideas?




Aucun commentaire:

Enregistrer un commentaire