Last active
August 15, 2017 13:32
-
-
Save montyanderson/8d6c24d44f28f845e780b9731a02dfd2 to your computer and use it in GitHub Desktop.
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 | |
function randomId($length) { | |
$chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
$max = strlen($chars) - 1; | |
$id = ""; | |
for($i = 0; $i < $length; $i++) { | |
$id .= $chars[random_int(0, $max)]; | |
} | |
return $id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment