Re: Re: rand_str

From: Date: Sun, 05 Aug 2001 12:52:11 +0000
Subject: Re: Re: rand_str
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-62143@lists.php.net to get a copy of this message
I think that new functions should be added on basis of usefulness, not the "coolness" factor. IMNSHO this function isn't very useful, and it is extremely easy to implement in userland: function str_rand() { $len = func_num_args() ? func_get_arg(0) : 32 ; return substr(md5(microtime()),0,$len); } At 13:57 8/5/2001, Daniel Andersson wrote the following: -------------------------------------------------------------- >i would say so, yes. > >and if you do md5(microtime()) you have to do a substr() on the result to >get the desired length. > >easy done, yes. but still.. > >maybe something for PEAR instead of the core? > >/ d > > >----- Original Message ----- >From: "Cynic" <cynic@mail.cz> >To: "Daniel Andersson" <daniel@avantnoise.com>; <php-dev@lists.php.net> >Sent: Sunday, August 05, 2001 3:41 >Subject: Re: [PHP-DEV] Re: rand_str > > >> is it that much more useful than md5(microtime()) ? >> ah-oh, you want to be able to specify the set of characters... >> >> At 04:28 8/5/2001, Daniel Andersson wrote the following: >> -------------------------------------------------------------- >> >sounds useful and cool, me thinks :o) >> > >> >/ d >> > >> ><jeroen@php.net> wrote in message >> >news:20010804205438.88378.qmail@pb1.pair.com... >> >> Hi, >> >> >> >> I'm thinking about a new function: [mt_]rand_str >> >> >> >> Syntax: >> >> string [mt_]rand_str(minlen,maxlen[,charlist]); >> >> >> >> where charlist is in addcslashes (and now also [l|r]trim) syntax. >> >> Charlist defaults to 0..9a..zA..Z >> >> >> >> >> >> IMHO, this would be a very useful function. >> >> >> >> Any comments? Maybe not min&maxlen, but simply a fixed len? (since >> >> randomness on the length is ambigious to implement, there are less >> >> possibilities with shorter strings, which raises some issues). >> >> >> >> As an extension, the function could also accept an array as charlist, >> >> containing small strings, to produce pronouncable strings. >> >> >> >> Jeroen >> >> >> >> >> >> >> >> >> > >> > >> > >> >-- >> >PHP Development Mailing List >> ><http://www.php.net/> >> >To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net >> >For additional commands, e-mail: php-dev-help@lists.php.net >> >To contact the list administrators, e-mail: php-list-admin@lists.php.net >> ------end of quote------ >> >> >> cynic@mail.cz >> ------------- >> And the eyes of them both were opened and they saw that their files >> were world readable and writable, so they chmoded 600 their files. >> - Book of Installation chapt 3 sec 7 >> > > >-- >PHP Development Mailing List <http://www.php.net/> >To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net >For additional commands, e-mail: php-dev-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net ------end of quote------ cynic@mail.cz ------------- And the eyes of them both were opened and they saw that their files were world readable and writable, so they chmoded 600 their files. - Book of Installation chapt 3 sec 7

« previous php.dev (#62143) next »