You are here: Re: generate 2 random numbers in rapid sequence « PHP Programming Language « IT news, forums, messages
Re: generate 2 random numbers in rapid sequence

Posted by Jim Michaels on 04/23/06 04:32

"Domestos" <andy.mak@virgin.netspam> wrote in message
news:1DA2g.22612$LH2.15753@newsfe2-win.ntli.net...
>A less computationally expensive method of accomplishing the same thing is
>to use the mt_rand() function. This function uses the Mersenne Twister
>algorithm and is considerably faster than rand(). In addition as of PHP
>version 4.2.0 there is no need to seed the mt_rand() random number
>generator with srand() or mt_srand()
>
> <?php
>
> // Range of numbers
>
> // Minimum number
> $min = "1";
>
> // Maximum number
> $max = "10";
>
> echo "mt_rand() Mersenne Twister pseudo-random number: ".
> mt_rand($min, $max);
>
> ?>
>

I know about these. that's why I mentioned them. my problem, as I stated,
is that when I use them in an inline image generator to randomly select an
image from a database, I get the same images on the page. I refresh, I get a
different image because microtime has changed, but both images are again the
same.

This is supposed to be a random image picker. I don't even care if it's
pseudo-random, as long as I get something that looks like a different image
every time.

any ideas?

 

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

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