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

Posted by Geoff Berrow on 06/14/05 13:22

I noticed that Message-ID: <av4ta1h08up98hikop6q8jldgsihobqkpn@4ax.com>
from Ewoud Dronkert contained the following:

>On Mon, 13 Jun 2005 23:54:08 +0100, Geoff Berrow wrote:
>> for($i=1;$i<50;$i++){
>> $balls[]=$i;
>> }
>
>See http://php.net/range

Code is from a course I run and it's a good idea to get the students
used to using loops
>
>> for($i=0;$i<6;$i++){
>> $key=array_rand($balls);
>> $ballschosen[]=$balls[$key];
>> unset($balls[$key]);
>> }
>
>See http://php.net/shuffle

For some reason I've never been able to get shuffle to work properly.
>
>> asort($ballschosen);
>
>Why use asort when you don't use the keys? See http://php.net/asort

Seemed like a good idea at the time :)
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

 

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

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