PHP 8.4.24 Released!

Voting

: max(five, nine)?
(Example: nine)

The Note You're Voting On

ccb2357 at gmail dot com
3 years ago
<?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);
    }
?>

<< Back to user notes page

To Top