You are here: Re: Pseudo Random Sequence « PHP Programming Language « IT news, forums, messages
Re: Pseudo Random Sequence

Posted by Philip Ronan on 11/10/05 20:13

"Nel" wrote:

> The problem is displaying the contents of an array in what appears to be
> random order, but in fact is a set sequence depending on a given value (e.g.
> the day of the month).

(snip)

> The order itself is not important, but what is important is the apparent
> random sequence is really repeatable.

Seed the random number generator based on the day of the month and use
array_rand() to shuffle the contents

$day = 1 * date('j');
srand($day);
$random_array = array_rand($array);

(I haven't tested this, but it ought to work)

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/

 

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

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