On Sat, 23 Aug 2003 15:06:32 +0200 (CEST), you wrote: >In my mysql db i have a colum called names; > >In names their are: > >Frank >Frank >Bob >Alice >Bob >Alice >Jim >Alice >Frank > >I want to make a random selection (max 3 value's for example).. Only it may not >produce two times the same name. For example;
First make sure the array values are distinct: $array = array_unique ($array); Then shuffle the array: shuffle ($array); Then slice the array down to size: if (sizeof ($array) > 3) { $array = array_slice ($array, 0, 3); } There are faster ways, but this is probably the shortest code snippet. BTW, if a value appears multiple times in a database column then your database may be a good candidate for normalisation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php