note 128396 added to function.str-shuffle
| From: | ccb2357 at gmail dot com | Date: | Fri, 14 Apr 2023 05:39:35 +0000 |
| Subject: | note 128396 added to function.str-shuffle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220351@lists.php.net to get a copy of this message | ||
<?php
function str_rand(int $length = 20) : string {
$ascii_codes = range(48, 57) + range(97, 122);
$codes_lenght = (count($ascii_codes)-1);
shuffle($ascii_codes);
$string = '';
for($i = 1; $i <= $length; $i++){
$previous_char = $char ?? '';
$char = chr($ascii_codes[random_int(0, $codes_lenght)]);
while($char == $previous_char){
$char = chr($ascii_codes[random_int(0, $codes_lenght)]);
}
$string .= $char;
}
return str_shuffle($string);
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 177.124.1.235)
----
Manual Page -- https://php.net/manual/en/function.str-shuffle.php
Edit -- https://main.php.net/note/edit/128396
Del: integrated -- https://main.php.net/note/delete/128396/integrated
Del: useless -- https://main.php.net/note/delete/128396/useless
Del: bad code -- https://main.php.net/note/delete/128396/bad+code
Del: spam -- https://main.php.net/note/delete/128396/spam
Del: non-english -- https://main.php.net/note/delete/128396/non-english
Del: in docs -- https://main.php.net/note/delete/128396/in+docs
Del: other reasons-- https://main.php.net/note/delete/128396
Reject -- https://main.php.net/note/reject/128396
Search -- https://main.php.net/manage/user-notes.php