Re: Random Images with no duplicates?
| From: | Silvio Porcellana [tradeOver] | Date: | Sun, 18 Dec 2005 10:08:42 +0000 |
| Subject: | Re: Random Images with no duplicates? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-227595@lists.php.net to get a copy of this message | ||
Silvio Porcellana [tradeOver] wrote:
>
> <code>
> $file = "images.txt";
> $openFile = file($file);
> $num_images = 10;
> # don't need this is PHP > 4.2.0
> srand((float) microtime() * 10000000);
> $random_keys = array_rand($openFile, $num_images);
> foreach ($random_keys as $random_key) {
> echo "<img src='$random_image' height='170'
> width='100'></img>";
ops, sorry, that obviously should be:
echo "<img src='" . $openFile[$random_key] . "' height='170'
width='100'></img>";
> }
> </code>
Sorry about this!
Silvio
--
tradeOver | http://www.tradeover.net
...ready to become the King of the World?