$links = array( 'http://www.link1.com/', 'http://www.link2.com/', 'http://www.link3.com/', 'http://www.link4.com/' ); for ($x = 0; $x <= 4; ++$x) { $link .= $links[rand(0, count($links)-1)].'<br>'; }