Hallo liebe Com ich habe mal eine Frage:
Wie Generiere ich in PHP ein Key generator
also er soll dann so aus sehen
XXXX-XXXX-XXXX-XXXX
Aber da sollen halt immer verschidene sein also komplett zufällig
184f-ti3t-86gj-j6g6
9265-gh6h-gvh4-iutq
...
Hallo liebe Com ich habe mal eine Frage:
Wie Generiere ich in PHP ein Key generator
also er soll dann so aus sehen
XXXX-XXXX-XXXX-XXXX
Aber da sollen halt immer verschidene sein also komplett zufällig
184f-ti3t-86gj-j6g6
9265-gh6h-gvh4-iutq
...
...
<?php
$random = rand(1, 3); $string = "";
if ($random == 1) {
$nextrand = rand(0,9);
$string = $string.$nextrand;
}
else if ($random == 2) {
$nextrand = rand(1,26);
$string = $string.str_replace(array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"), array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"), $nextrand);
}
else {
$nextrand = rand(1,26);
$string = $string.strtoupper(str_replace(array("0", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "20", "21", "22", "23", "24", "25", "26"), array("a", "b", "c",
"d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
"r", "s", "t", "u", "v", "w", "x", "y", "z"), $nextrand));
}
echo $string;
?>
Alles anzeigen