I used this for a gender random 12 character string:
// lost-in-code.com/programming/php-code/php-random-string-with-numbers-and-letters
$ch = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@$%^&(){}[]+=-_/?|*#";
$sc = "";
for ($p = 0; $p < 12; $p++) {
$sc .= $ch[mt_rand(0,82)]; // 83 is the strlen of characters
}
It turns out that in practice it may contain a space in the line. This is not expected!
Why? Does this underline look like space? This caused random (and still unmanageable) errors.
Thank.
Nick source
share