$freq, 'URL' => $URL ); $list['sum'] += $freq; return $list; } function draw_random($list) { $randomnumber = mt_rand(0, $list['sum'] - 1); for ($pos = 0; ; $pos ++) if ($randomnumber < $list[$pos]['freq']) return $list[$pos]['URL']; else $randomnumber -= $list[$pos]['freq']; } $elements = array('count' => 0, 'sum' => 0); /* ADD ELEMENTS HERE Just copy the line and modify the last two values. The number is the frequency, the third thing is the site. So, these lines $elements = add_element($elements, 1, 'http://google.com'); $elements = add_element($elements, 4, 'http://jiggmin.com'); would add google.com with a frequency of 1 (out of the total, which is 1 + 4 = 5) and jiggmin.com with a frequency of 4. If you're unsure about the frequency, just put 1 for every site. */ $elements = add_element($elements, 1, 'http://google.com'); $elements = add_element($elements, 4, 'http://jiggmin.com'); if ($elements['sum'] == 0) die ('No links'); $finallink = draw_random($elements); $result = << HTMLcode_end; echo $result; ?>