Re: Re: rand_str

From: Date: Sun, 05 Aug 2001 15:01:06 +0000
Subject: Re: Re: rand_str
References: 1 2 3 4  Groups: php.dev 
Request: Send a blank email to php-dev+get-62151@lists.php.net to get a copy of this message
heh.. possibly. ;) forwarded. / d ----- Original Message ----- From: "Cynic" <cynic@mail.cz> To: "Daniel Andersson" <daniel@avantnoise.com>; <php-dev@lists.php.net> Sent: Sunday, August 05, 2001 15:59 Subject: Re: [PHP-DEV] Re: rand_str > I'm not against putting it into pear. ask the pear guys > what they think... but there's no Strings class AFAIK, and > I think they'll hesitate to create a top-level class for just > one function. :) > > At 16:47 8/5/2001, Daniel Andersson wrote the following: > -------------------------------------------------------------- > >yes, totally agree. > > > >but why not put it into PEAR? > > > >/ d > > > >----- Original Message ----- > >From: "Cynic" <cynic@mail.cz> > >To: "Daniel Andersson" <daniel@avantnoise.com>; > ><php-dev@lists.php.net> > >Sent: Sunday, August 05, 2001 13:52 > >Subject: Re: [PHP-DEV] Re: rand_str > > > > > >> 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

« previous php.dev (#62151) next »