Domcsore Posted April 15, 2010 Share Posted April 15, 2010 Okay I've had so many ideas on how to do probability but when it comes to practice it's a little more difficult than I thought. Okay so what I am trying to create is a random advertisements script. So far I have this: public function adImage(){ $adimgLink[1] = 'template/template_files/ad_images/adhere.jpg'; $noAds = (count($adimgLink)); $randAd = rand(1,$noAds); echo '<img src="'.$adimgLink[$randAd].'" />'; } This works, however, I want it so customers can have a higher or lower probability of showing up depending on their budget they wish to spend on their advertisement. Any ideas? all help is appreciated =) Link to comment https://forums.phpfreaks.com/topic/198680-probability-question/ Share on other sites More sharing options...
SaMike Posted April 18, 2010 Share Posted April 18, 2010 How about you assign multiple numbers to ads? Like numbers 1 to 10 would be ad1, and 11 to 15 would be ad2, then rand(1, 15) Link to comment https://forums.phpfreaks.com/topic/198680-probability-question/#findComment-1044124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.