Created
July 20, 2015 08:49
-
-
Save vlrmprjct/34aba65aa368db4a5300 to your computer and use it in GitHub Desktop.
Get a random alphanumeric string.
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
/** | |
* @param $prefix | |
* @param $suffix | |
* @param $size | |
* | |
* @return string | |
*/ | |
private function randomKey($prefix, $suffix, $size) | |
{ | |
$key = ""; | |
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
for ($i = 0; $i < $size; $i++) | |
{ | |
$key .= $chars[rand(0, strlen($chars) - 1)]; | |
} | |
return $prefix . $key . $suffix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment