Last active
June 13, 2018 17:01
-
-
Save shawn-crigger/01e9299b63affb5524fc70f9a195db7b to your computer and use it in GitHub Desktop.
Returns random characters
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
function _make_token( $length = 16 ) | |
{ | |
$token = ""; | |
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz"; | |
$codeAlphabet.= "0123456789"; | |
$max = strlen($codeAlphabet); // edited | |
for ($i=0; $i < $length; $i++) { | |
token .= $codeAlphabet[random_int(0, $max-1)]; | |
} | |
return $token; | |
} |
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 | |
$length = 8; | |
$x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
$name = substr( str_shuffle( str_repeat( $x, ceil( $length / strlen( $x ) ) )), 1, $length ); | |
$name = str_replace( array( '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', ), '', $name ); | |
$two = substr( $name, 0, 2 ); | |
$path = $root . $two . '/'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment