Last active
September 8, 2023 18:43
-
-
Save podlom/2e6ab76fc1ca50528b941879e52402dd to your computer and use it in GitHub Desktop.
Random strings generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$randomCode = ''; | |
define('STR_LEN', 8); | |
$characters = array_merge(range('a', 'z'), range(0, 9)); | |
// echo 'The $characters: ' . var_export($characters, true) . PHP_EOL; | |
shuffle($characters); | |
// echo 'all shuffled characters: ' . var_export($characters, true) . PHP_EOL; | |
for ($i = 0; $i < STR_LEN; $i++) { | |
$randomCode .= $characters[$i]; | |
} | |
echo 'Random code: ' . var_export($randomCode, true) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment