matthijs166
10/27/2017 - 12:53 PM

Shuffle with a seed

shuffle a array with a seed

//randomnizer with seed
function fyshuffle(&$items,$seedstring) {
	if (!$seedstring) {
		$seedval = time();
	} else {
		if (is_numeric($seedstring)) {
			$seedval = $seedstring;
		} else {
			$seedval = crc32($seedstring);
		}
	}

	srand($seedval);
	for ($i = count($items) - 1; $i > 0; $i--) {
		$j = @rand(0, $i);
		$tmp = $items[$i];
		$items[$i] = $items[$j];
		$items[$j] = $tmp;
	}
}