Random string generator PHP -
this question has answer here:
- php random string generator 42 answers
i'm trying create random string numbers , letters , found function , thought good, don't know if correct way create true random string or if there easier way this? below have:
function randomgen() { $chars = '0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; $length = strlen($chars); $random; ($i = 0; $i < 8; $i++) { $random = $chars[rand(0, $length - 1)]; } return $random; }
you try using $random = substr(str_shuffle(md5(microtime())), 0, 8);
, output same amount of random characters have in example. prefer method on doesn't require put in expected characters , more importantly, can done in 1 line of code!
Comments
Post a Comment