You are here: Re: random without replacement « PHP Programming Language « IT news, forums, messages
Re: random without replacement

Posted by windandwaves on 11/18/96 11:42

Mladen Gogala wrote:
> On Wed, 15 Mar 2006 23:05:09 +1300, windandwaves wrote:
>
>> I want a random list of numbers between 0 and 58 where each number
>> can only occur once. I have written this ($f is an array):
>
> You should use shuffle() function. Are you trying to win powerball?

Not sure about the powerball thing. But this is how I did it in the end:

function randomizer($array, $itemsneeded) {
$r = array_rand($array, $itemsneeded);
foreach($r as $c) {
$v[$c] = $array[$c];
}
return $v;
}

 

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

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