<?php
define('TEST_VALUE_COUNT', 5000);
srand(15);
$values = array();
for ($i = 0; $i < TEST_VALUE_COUNT; $i++) {
$values[] = rand();
}
srand(15);
foreach($values as $key => $value) {
if ($value !== rand()) {
print "Bad value at " . $key;
exit;
}
}
echo "All were the same in " . count($values) . " values";
srand(15);
shuffle($values);
$valuesShuffled = array_merge(array(), $values);
srand(15);
shuffle($values);
if (count(array_diff_assoc($values, $valuesShuffled)) == 0) {
echo "Shuffle was the same after a shuffle";
} else {
echo "Array was not the same after a seeded shuffle\n";
}