Randomize an array?

I have 3 arrays, $list1, $list2, and $list3. Each of the three has 10 elements, Im trying to randiomize 1 array,


shuffle($list1);

But how do I make it so that the new order is carried over to the other two arrays?
You can see the three arrays printed out

http://shores-rentals.com/luth/question8.php

Thanks…

Use the numerical key values from the first for the others.

One way would be to set up an extra array and shuffle that.

$list0 = array(0,1,2,3,4,5,6,7,8,9);
shuffle($list0);

Now the numbers in this extra array can be used as the index into the other three arrays so that you access the corresponding entries in all three of your original arrays without changing their order at all but simply changing the order in which you access the entries from sequential to the random order specified in the extra array.

for ($i = 0; $i < 10; ++$i) {
   echo $list1[$list0[$i]].' : '.$list2[$list0[$i]].' : '.$list3[$list0[$i]].'<br>';
}

thanks felgall (ill try that)

How would I grab the key values if this is how to randomize the array,

shuffle($list1); 

I created a master array, but now whewn I try to pring out each arrqay like


echo "<ol>";
foreach($list1 as $value) {
echo "<li>".$master[$value]."</li>";
}
echo "</ol>";
echo "</td><td>";
echo "<ol>";
foreach($list2 as $value) {
echo "<li>".$master[$value]."</li>";
}
echo "</ol>";
echo "</td><td>";
echo "<ol>";
foreach($list3 as $value) {
echo "<li>".$master[$value]."</li>";
}
echo "</ol>";
echo "</td></tr>";
echo "</table>";


I get nothing

thank you, that worked, the thing that’s odd to me is the for loop, why do you have ++$i and not $i++?

This ought to give you the insight behind that
http://stackoverflow.com/questions/24853/what-is-the-difference-between-i-and-i