Yup, that's the roulette selection, as they call it. It's pretty simple,
actually. The idea is that you use a concept similar to a roulette table,
just that the sectors aren't equal -- they're equal to their respective
weights. The procedure is as follows:

1. Assign the weighting to each of the pages;
2. Create an array with the pages' URL's;
3. Create an array with the same size as (2), with the weights of each
respective page to the same index as the URL's;
4. Find out the sum of all values in the array at (3);
5. Generate a random number between 0 and the number found out at (4);
6. Walk (3) while sum of elements in (3) you already walked is smaller than
(5). When the condition is false, remember the index;
7. (6)-1 is the index in (2) you need.

If you need more info, don't hesitate to ask me!


John Hawkins wrote:

> I have an internal project I'm working on where I
> would like to randomly send visitors to different
> pages, but, I want to be able to give some pages a
> better chance of getting shown.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to