You are here: Re: Random Number Excluding Specified Value in Array « PHP Programming Language « IT news, forums, messages
Re: Random Number Excluding Specified Value in Array

Posted by boclair on 07/18/06 04:52

AP wrote:
> Hello
> Any suggestions on the most efficient way to generate a random number
> from a range that will not return values specified in an array?
>

No doubt better methods but a quick thought

$fulllist = range(1, 12);
shuffle($fulllist);
$vetolist = array (2,3,7,8);

$alive = array_diff($fulllist, $vetolist);

foreach ($alive as $value) {
echo "$value, ";
}

Louise

 

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

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