Re: [PHP] Randomiser

2008-10-19 Thread Reese
Chris wrote: That works, but shuffle() is cleaner and then you can echo things out with a foreach() expression. http://www.php.net/manual/en/function.shuffle.php If you're doing a shuffle inside a loop, it's going to be even slower. Might not be an issue for the OP but after your array gets

Re: [PHP] Randomiser

2008-10-19 Thread Chris
Reese wrote: Andrew Barnett wrote: I ended up using an example from the PHP website. Just extended the array to the number of lines I needed. That works, but shuffle() is cleaner and then you can echo things out with a foreach() expression. http://www.php.net/manual/en/function.shuffle.php

Re: [PHP] Randomiser

2008-10-19 Thread Reese
Andrew Barnett wrote: I ended up using an example from the PHP website. Just extended the array to the number of lines I needed. That works, but shuffle() is cleaner and then you can echo things out with a foreach() expression. http://www.php.net/manual/en/function.shuffle.php Reese -- P

Re: [PHP] Randomiser

2008-10-19 Thread Chris
Andrew Barnett wrote: I ended up using an example from the PHP website. You're randomizing the whole array which when it gets large, will be noticeable. If you're using zero based arrays (like above - 'Neo' is item '0', 'Morpheus' is item '1'), I'd suggest something like this: $input = a

Re: [PHP] Randomiser

2008-10-17 Thread Andrew Barnett
I ended up using an example from the PHP website. Just extended the array to the number of lines I needed. Andrew

Re: [PHP] Randomiser

2008-10-16 Thread Chris
Andrew Barnett wrote: Hey All, I'm trying to work out how to randomise the order of a bunch of strings I have. I know how to pick one random string from a bunch of them, but how do I make sure that everyone is used just once. $used_strings = array(); while (true) { $string = get_random_string

Re: [PHP] Randomiser

2008-10-16 Thread Bastien Koert
On Thu, Oct 16, 2008 at 8:22 PM, Andrew Barnett <[EMAIL PROTECTED]>wrote: > Hey All, > I'm trying to work out how to randomise the order of a bunch of strings I > have. I know how to pick one random string from a bunch of them, but how do > I make sure that everyone is used just once. > > Any poin