...

View Full Version : Predictable array shuffle



bauhsoj
09-14-2005, 03:52 AM
How would I get the function shuffle() to always "randomize" the array in a predictable manner? In other words, given the exact same information how would I get it to shuffle the array in exactly the same way?

bauhsoj
09-14-2005, 04:40 AM
I am thinking this is the answer to my problem, but am unsure.

What I need is to predictably shuffle the array which contains a string broken into pieces by spaces.



$array = explode(' ', $string);
srand(crc32($string));
shuffle($array);

Will the above provide a predictable shuffling at all times? This is easy enough to test but I want to be certain.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum