Skip to content

Instantly share code, notes, and snippets.

@TheAnarchoX
Created December 12, 2017 10:49
Show Gist options
  • Save TheAnarchoX/569d02f06f5aa45deeda01de0453e7fc to your computer and use it in GitHub Desktop.
Save TheAnarchoX/569d02f06f5aa45deeda01de0453e7fc to your computer and use it in GitHub Desktop.
/**
* @param int $length
* @param int $count
* @return int
*/
public static function generateSeed($length, $count) : int {
$prim = random_int(10**($length-1), (10**($length))-1);
$sub = (array) str_split($prim);
for ($i = 0; $i <= count($sub) - 1; $i++) {
$sub[$i] = (string) $sub[$i]%$count;
}
$seed = (int) implode($sub);
return $seed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment