RE: [PHP] Random string

From: Date: Fri, 15 Sep 2000 05:01:57 +0000
Subject: RE: [PHP] Random string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16894@lists.php.net to get a copy of this message
Here's something that I've used: $new_password = substr(md5(uniqid(rand())), 0, 8); regards - Jason Wong Digital View Ltd 2201 Nanyang Plaza 57 Hung To Road Kwun Tong HONG KONG Tel: +852-2861-3615 Fax: +852-2520-2987 www.digitalview.com > -----Original Message----- > From: n e t b r a i n [mailto:net-brain@net-brain.net] > Sent: 15 September 2000 16:17 > To: php-general@lists.php.net > Subject: [PHP] Random string > > > > Hi, > > I'm in trouble in order to implement a small function for a random > alphanumeric string of 8 charcters lenght (well, I mean: a > password of 8 > chars ...) > > Reading the Wrox php book, I've founded this: > > function random($lenght) { > > $possibili="0123456789+-zxcvbnmlkjhgfdsapoiuytrewqZXCVBNMLKJHGF > DSAPOIUYTREWQ > "; > $stringa=" "; > while(strlen($stringa) < $lenght) { > $stringa .=substr($possibili, mt_rand(0, > strlen($possibili) -1), 1); > } > echo($stringa); > } > random(8); > > But the main problem is that it seem doesn't work ... infact it produce > often a php_time_out ... > > Anyone could help me with suggestion or show me a small > snippet of code in > order to create unique passwords of 8 chars? > > Many thanks in advance. > max > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.general (#16894) next »