Re: Re: rand_str

From: Date: Sun, 05 Aug 2001 19:50:17 +0000
Subject: Re: Re: rand_str
References: 1 2 3 4 5  Groups: php.dev 
Request: Send a blank email to php-dev+get-62170@lists.php.net to get a copy of this message
At 21:17 8/5/2001, Jeroen van Wolffelaar wrote the following: -------------------------------------------------------------- [...] >> function str_rand($len=8) >> { >> $retval = strtr(md5(microtime()), chr(0x30), chr(0x4F)); >> return substr($retval,0,$len); >> } >> >> for($i=0; $i<10; $i++){ >> echo str_rand(), "\n"; >> } > >I find rand_str($len , "1..9a..f\x4F") easier... ;-) >And this is still yielding exactly 16 differerent characters. > >As you saw for yourself, it is not trivial to implement something like this >in userland. For example str_pad is way easier to implement, only some >playing with str_repeat. > >Are there any objections if I implement this? Are you still against this new >function? > >Jeroen Hi Jeroen, I think we're not on the same page. :) I consider both versions of str_rand() I posted trivial... Also, and this is strictly subjective, I don't think the function needs to be implemented natively. As I said, it's trivial. :) But my stance could be rated as -0.3... Actually, as I'm thinking about it, -0.2. as for the rand_str($len , "1..9a..f\x4F") proto: I don't like it. KISS. 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 (#62170) next »