Forum Moderators: coopster
I need help. I want to use 'mt_rand()', to print a series of links in different order. I thought about using an array.
How can I do this so the same link isnt printed twice, or some of the links don't appear.
It's so I can produce a list of links in random order so nobody gets missed out.
Any idea how?
Jon
$links= array("www.site1.com","www.site2.com","www.site3.com");
$linkT=array("site1","site2","site3");
$r=rand(0,2);
<a href="<? echo ("http://$links[$r]");?>"><? echo $linkT[$r];?></a>
function dump_rand_links ($links) {
srand((float)microtime() * 1000000);
shuffle($links);
foreach ($links as $link) {
echo "<a href=\"{$link}\">{$link}</a><br />";
}
}