Moin,
ich habe mir einen kleinen Zufallsgenerator gecodet. Ich wollte fragen was ich daran noch besser machen kann. Ist erstmal nur der prototyp, später soll natürlich alles noch vom nutzer bestimmbar sein.
Vielen Dank,
Grüße anghenfil
ich habe mir einen kleinen Zufallsgenerator gecodet. Ich wollte fragen was ich daran noch besser machen kann. Ist erstmal nur der prototyp, später soll natürlich alles noch vom nutzer bestimmbar sein.
PHP-Code:
<?
echo'Zufallsgenerator:';
error_reporting: -1;
//Stellen:
$stellen = 10;
//Pools:
$abc = true;
$ABC = true;
$num = true;
$snz = true;
$abcpool = 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");
$ABCpool = 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");
$numpool = array(1,2,3,4,5,6,7,8,9,0);
$snzpool = array("!", "$", "%", "&", "/", "(", ")", "=", "?", "-", "_", ".", ":", ";", ",","<", ">");
if($abc == true)
if(empty($pool))
$pool = $abcpool;
else
$pool = array_merge($pool, $abcpool);
if($ABC == true)
if(empty($pool))
$pool = $ABC;
else
$pool = array_merge($pool, $ABCpool);
if($num == true)
if(empty($pool))
$pool = $numpool;
else
$pool = array_merge($pool, $numpool);
if($snz == true)
if(empty($pool))
$pool = $snzpool;
else
$pool = array_merge($pool, $snzpool);
$werte = count($pool) - 1;
for ($n=1;$n<=$stellen;$n++)
$str = $str . $pool[mt_rand(0, $werte)];
echo $str;
?>
Grüße anghenfil
Kommentar