You are here: Re: Not generating the same random number twice.... « All PHP « IT news, forums, messages
Re: Not generating the same random number twice....

Posted by Geoff Berrow on 06/14/05 01:54

I noticed that Message-ID:
<1118689179.0bfe721d1be71944ad69de19a67d3613@teranews> from Mark
contained the following:

>The problem is that there is nothing to stop images appearing more than
>once. I do not want this to happen...
>
>Any ideas on a possible solution?

The following picks lottery balls (6 unique balls out of 49) Trivial to
adapt it to what you want.

<html>
<body style="color:red"><?php

for($i=1;$i<50;$i++){
$balls[]=$i;
}

for($i=0;$i<6;$i++){
$key=array_rand($balls);
$ballschosen[]=$balls[$key];
unset($balls[$key]);
}

asort($ballschosen);

foreach($ballschosen as $choice){
print"$choice ";
}

?>
</body>
</html>

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация