Hey, I'm trying to create my own ad block like Adsense but with my own affiliate links. So I need to create two unique random numbers from which I will select the appropriate block of code. Not sure why I'm finding this so difficult, but here's what I've got so far:

$ad1 = rand(0,3);
while ($ad1 != rand(0,3)) {
$ad2 = rand(0,3);}

But there are times, of course, where the numbers will be the same as there is no dependency between the rand functions in the while loop.

Any ideas?

Thanks a lot.

    You could do something like this:

    $ad1 = rand(0,3);
    while (($ad2 = rand(0,3)) == $ad1)
    	/* Do nothing. */;

    Alternatively, you could use [man]array_rand/man.

      Write a Reply...