You are here: Re: Random sequence without repeats? « All PHP « IT news, forums, messages
Re: Random sequence without repeats?

Posted by tom on 07/22/05 14:27

On Fri, 22 Jul 2005 12:02:40 +0200, Arjen <arjen@mailmaarnietpuntenel.nl>
wrote:

>John wrote:
>> mark wrote:
>>
>>> I have 4 colors, red, blue, yellow, green in an array. I wish to
>>> display 3 of them on a page at ramdon without repeating one on the
>>> same page. So, refresh = yellow, green, blue | refresh = red, blue,
>>> yellow.....etc etc...
>>>
>>> Can someone point me in the direction of the function I should be
>>> looking to us to use to stop two colors appearing twice?
>>>
>>
>> The colours can be given indexes 0, 1, 2, 3. You simply have to decide
>> which index you DON'T want to display.
>>
>> Generate a random number between 0 and 3 (inclusive) and then don't
>> display the colour with that index.
>>
>> John
>
>Not entirely true. That still wont randomize the colours. You would have to eliminate that colour and then randimzie the array.
>
>Better to randmonze the array of colours and then simple retrieve $array[0], $array[1], $array[2] :-)
>
>Arjen
http://uk2.php.net/manual/en/function.shuffle.php
talks about shuffle. Does anyone know, does this produce the same shuffle
every time?

 

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

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