Ich habe mir ein Programm geschrieben, dass 8stelllige Zufallszahlen ermittelt.
<?php
$the_char = array(
//"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h",
//"H","i","I","j","J", "k","K","l","L","m","M","n","N","o","O",
//"p","P","q","Q","r","R","s","S","t","T", "u","U","v","V","w",
//"W","x","X","y","Y","z","Z" ,
"1","2","3","4","5","6","7","8",
"9","0"
);
$max_elements = count($the_char) - 1;
mt_srand(time());
$c1 = $the_char[mt_rand(0,$max_elements)];
$c2 = $the_char[mt_rand(0,$max_elements)];
$c3 = $the_char[mt_rand(0,$max_elements)];
$c4 = $the_char[mt_rand(0,$max_elements)];
$c5 = $the_char[mt_rand(0,$max_elements)];
$c6 = $the_char[mt_rand(0,$max_elements)];
$c7 = $the_char[mt_rand(0,$max_elements)];
$c8 = $the_char[mt_rand(0,$max_elements)];
$the_char =array_values ($the_char);
$nummer = $c1.$c2.$c3.$c4.$c5.$c6.$c7.$c8 ;
//echo "<P><A HREF=$PHP_SELF>Prepaidnummer generieren</A>";
?>
Wie gelingt es mir damit auf einmal eine n-Anzahl an Werten generienen zu lassen und diese in eine MySQL Datenbank zu schreiben.
Ich gebe 50 als Menge ein und das Programm muss mir 50 verschiendene Zufallszahlen in einen Datenbank schreiben.
<?php
$the_char = array(
//"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h",
//"H","i","I","j","J", "k","K","l","L","m","M","n","N","o","O",
//"p","P","q","Q","r","R","s","S","t","T", "u","U","v","V","w",
//"W","x","X","y","Y","z","Z" ,
"1","2","3","4","5","6","7","8",
"9","0"
);
$max_elements = count($the_char) - 1;
mt_srand(time());
$c1 = $the_char[mt_rand(0,$max_elements)];
$c2 = $the_char[mt_rand(0,$max_elements)];
$c3 = $the_char[mt_rand(0,$max_elements)];
$c4 = $the_char[mt_rand(0,$max_elements)];
$c5 = $the_char[mt_rand(0,$max_elements)];
$c6 = $the_char[mt_rand(0,$max_elements)];
$c7 = $the_char[mt_rand(0,$max_elements)];
$c8 = $the_char[mt_rand(0,$max_elements)];
$the_char =array_values ($the_char);
$nummer = $c1.$c2.$c3.$c4.$c5.$c6.$c7.$c8 ;
//echo "<P><A HREF=$PHP_SELF>Prepaidnummer generieren</A>";
?>
Wie gelingt es mir damit auf einmal eine n-Anzahl an Werten generienen zu lassen und diese in eine MySQL Datenbank zu schreiben.
Ich gebe 50 als Menge ein und das Programm muss mir 50 verschiendene Zufallszahlen in einen Datenbank schreiben.