Hi
On 6/17/22 19:46, Go Kudo wrote:
I was fundamentally wrong, I understand now.
As you said, there was no interoperability with `pickArrayKey()` in the
first place...
stringFromAlphabet()
Hmmm. I guess randomString would be better then. At the same time, it would
be nice to have an array version of randomArray.
However, I don't want to add more methods without any thought.
I think operations that can be done on userland should be done on userland.
That is why I did not implement the array_rand() function in the first
place.
Yes, I agree here. But I believe that "generate a string with a given
alphabet" is a very common operation that would be useful to include in
the standard library. In any case it's better to leave something out
than to implement something badly, so if you don't feel comfortable with
that, then leave it out. There will be more PHP versions after 8.2.
For me both of these:
->randomString(string $alphabet, int $length)
->stringFromAlphabet(string $alphabet, int $length)
with the description "Return a string of $length characters selected
from the given $alphabet. Characters may be selected more than once".
would be acceptable names.
Best regards
Tim Düsterhus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php