|
Posted by Carramba on 11/13/05 12:55
Hi!
I am working on script that ll generate some random data, ll need it later
on to fil db for testing.
but know to my problem, I have limited generation of data to different
char_sets depending on need, but
the generated data is mixing all char_sets and I dont se why , so actually
it's generates data on pwd condition, where all chat_set are allowed.
hope you can help!
<?php
function generateSign ( $var , $length ){
$charset_1 = "0123456789";
$charset_2 = "abcdfghjkmnopqrstvwxyz";
$charset_3 = "ABCDEFGHIJKLMNOPQRESTUVWXYZ";
$possible =""; //<-- I allways reset it to null (?)
if ( $var == 'num') {
$possible = $charset_1;
}
if ( $var = 'text'){
$possible = $charset_2;
$possible .= $charset_3;
}
if ( $var = 'pwd' ){
$possible = $charset_1;
$possible .= $charset_2;
$possible .= $charset_3;
}
if ( $var = null){
die('Use: text , num, pwd. In function');
}
$i = 0;
$password = "";
while ( $i < $length ) {
$sign = substr( $possible, rand( 0, strlen( $possible )-1 ), 1 );
if ( !strstr( $generatedData, $sign ) ) {
$generatedData .= $sign;
$i++;
}
}
return $generatedData;
}
$antal= 0;
while( $antal < 10 ){
$namn = strtolower( generateSign( 'text', '12' ) ); //<-- ll generate text
sting including numbers
$phone = generateSign('num', '8' );//<-- ll generate text sting including
char
$email = strtolower( generateSign('text' , '6' ) ); //<-- ll generate text
sting including numbers
$pwd = md5( generateSign('pwd', '4') );
echo $antal.' , '.$namn.' , '.$pwd.', '.$phone.' , '.$email.' <BR>';
$antal++;
}
?>
--
Thanx in advance
________________________
Navigation:
[Reply to this message]
|