Dotan Cohen wrote:
I've got an array $items which has about 200 entires. I want to print
them out in random order, but as usual, I have a catch! I need to add
a 'key' so that if need be, I can always return to the same 'random'
order, like so:

$items=predicatable_random($items, "qwerty");


Try using multi-dimensional arrays, something like:

<?php

$items = array(1,2,3,4,5,6,7,8,9,10);

for($i = 1, $random[0] = $items, shuffle($random[0]); $i < 10; $i++) {
  /* Initialize each pass with previous array, then randomize */
  $random[$i] = $items;
  shuffle($random[$i]);
}

$selected = rand(0,10);

echo "There are a total of " . count($random) . " randomly sorted arrays. Here are the randomly shuffled numbers for array number $selected.\n";

/* Now you can access each random array */
print_r($random[$selected]);

?>



--
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to