Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2005
    Posts
    470
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Predictable array shuffle

    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?

  • #2
    Regular Coder
    Join Date
    Jan 2005
    Posts
    470
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.

    PHP Code:
    $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.
    Last edited by bauhsoj; 09-14-2005 at 03:43 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •