Hi
On 6/20/22 07:20, Go Kudo wrote:
What about a signature like `Randomizer::pickArrayKeys(array $array, int
$num): array`?
The previous behavior when `int $num` is 1 can be easily reproduced as
follows:
```php
$randomizer = new Random\Randomizer(new Random\Engine\Mt19937(1234,
MT_RAND_PHP));
[$key] = $randomizer->pickArrayKeys(['foo', 'bar', 'baz'], 1);
```php
I like that one.
If multiple keys are returned, they will be returned in the order they
were present in the original array.
Perhaps there is no particular significance to this specification. I don't
think it is necessary, but considering the drop-in replacement from
array_rand(), I think it is desirable to leave it as is.
I agree.
Best regards
Tim Düsterhus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php