basketmen — 2012-07-31T03:35:58-04:00 — #1
Hi guys, how to do this in a php file
Showing ads only to 20% percent of visitors. Or showing different ads to another 80% visitors
any way that can work, maybe using time intervals, like the visitors that visit the site at minute 0-12 only that show it, and visitors that visit the site at minute 13-59 is not. Or another methode
please help or share if you have, this should be easy enough and many people should need it, already googling it but still cant found it
guido2004 — 2012-07-31T04:21:06-04:00 — #2
Maybe using rand(1, 100) ?
If the value is 1-20 show one add.
If the value is 21-100 show another.
Being a random generator, on large numbers it should give you your 20-80%.
starlion — 2012-07-31T08:43:43-04:00 — #3
well i'd suggest using mt_rand instead of rand, but yeah. Guido's answer is the correct one; you cant assume to have the same number of users each minute in order to do a by-time delivery and have it be (over time) accurate to 80/20.
cups — 2012-07-31T09:54:21-04:00 — #4
Just in case you really wanted to use start/end of hour:
echo (date('i') < 12 ) ? '<img src=banner1.jpg>' : '<img src=banner2.jpg>';