Re: PHP 7.1 - should we add a random_str() function?
| From: | Jordi Boggiano | Date: | Thu, 01 Oct 2015 23:03:08 +0000 |
| Subject: | Re: PHP 7.1 - should we add a random_str() function? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88627@lists.php.net to get a copy of this message | ||
On 30/09/2015 17:15, Scott Arciszewski wrote:
This is probably answerable by a quick yes/no and shouldn't need a ton of bikeshedding, but if that happens anyway I apologize in advance. I think random_bytes() and random_int() are great; they provide a much-needed building block in PHP 7.0. However, I do worry a bit that the most common use for random_int() (generating a random string of a fixed length with a given character set) will be reinvented over and over again, and rarely consistently. I would propose a random_str() function that behaves similar to this userland snippet: http://stackoverflow.com/a/32870871/2224584Sounds great, and the amount of different answers on this stack overflow question highlights the problem very well IMO. Cheers -- Jordi Boggiano @seldaek - http://seld.be