I had the same problem... I wrote a function that does this:

function scramble(&$array)
{
         // scrambles the elements of a one dimentional array
         // written by cblack ([EMAIL PROTECTED])
         // in php3 >= 3.0.8, there's a function called shuffle that does this
         for ($i=0;$i<sizeof($array);$i++)
         {
                 // seed random number generator
                 srand((double) microtime() * 1000000);

                 // store whatever is in $array[$i] in a temp var
                 $temp = $array[$i];

                 // generate a random number to swap with
                 $newvalue = rand(0, sizeof($array));

                 // swap values
                 $array[$i] = $array[$newvalue];
                 $array[$newvalue] = $temp;
         }

         return 1;
}

Feel free to modify...

CB

At 02:06 PM 2/1/01 -0500, Jason Jacobs wrote:
>Does anyone know of a function in version 3.0.7 that does the same thing to
>shuffle(), which was implemented in 3.0.8?  I'm trying to run a banner
>script I found, and I guess we were 1 one-hundredth of a version off for
>this thing...
>
>Or, how painless is it to upgrade to the latest version?  I'm assuming that
>PHP is backwards compatible...
>
>Thanks.
>Jason
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to