# [PHP] a set of *real* random numbers?

```
I want to show in random way 8 pictures (jpg) from a collection of 20 I have
,  so the users have more interest to visit the page.```
```
I use the follow small code with the help from the manual:
But the random numbers are all accending order  for 1 -> 20 and in cycle, as
the seed comes from computers timming.
So I get always the same sets of 8 numbers. (i.e. 1->8,  3->10,
15-16-17-18-19-20-1-2 ecc)

What can I use for seed for *real* rnd?

(I FOUND IT, I CHANGED  100000 to 10000000  AND IT WORKS!)

Makis Savaidis

======= the code ==>
<?php

// seed with microseconds
function make_seed() {
list(\$usec, \$sec) = explode(' ', microtime());
return (float) \$sec + ((float) \$usec * 100000);
}

// create 8 random numbers for 8 pictures - not doubles
\$arr = array ();
\$cnt2=0;
do  // 8 times
{
do  // produce rnd number
{
\$cnt=1; \$break=0;
srand(make_seed());
\$randval1 = rand(1,20); // for a palette of 20 pictures
echo (" rnd = \$randval1 <BR> ");
for (\$cnt1=1; \$cnt1<=\$cnt2; \$cnt1++) // check for doubles
{
if (\$arr[\$cnt1]==\$randval1)  \$break=1;

}
}  while (\$break==1);

\$cnt2++; \$arr[\$cnt2] = \$randval1;

echo(" cnt2 \$cnt2 arr1 \$arr[\$cnt2] <BR> ");

} while (\$cnt2<8);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

```