> >Implementing something that has NOT that limitation, is far less trivial.
>
> function str_rand($len = 8, $class = 'a-zA-Z1-9')
> {
>     static $init = 1;
>     if(1 == $init){
>         mt_srand((double) microtime() * 1000000);
>         $init = 0;
>     }
>     $chars = array();
>     for($i = 0; $i < $len; $i++){
>         $chars[] = chr(mt_rand(0,255));
>     }
>     return implode('', preg_grep('|['.preg_quote($class).']|',$chars));
> }
>
> Just a little bit different syntax for the second argument.
> What's the big deal? :)

Okay, but hey, you're a PHP-expert with probably many years of experience...
By the way, your function won't return strings of length $len... ;)
And you could say that preg_grep is quite a hack.


Anyway, this didn't convince me it's trivial... I'm sorry.

> >Better suggestions? Simple length and a list of characters... and the
> >list-of-characters way is also in addcslashes, and the trims.

Jeroen


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to