How to create a random string using PHP?
If you want to allow repetitive occurences of characters, you can use this function: function randString($length, $charset=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789″) { $str=””; $count = strlen($charset); while ($length–) { $str .= $charset[mt_rand(0, $count-1)]; } return $str; } The basic algorithm is to generate <length> times a random number between 0 and <number of characters> â 1 we use as …