Basically, I created this random string generator so that it is flexible enough to handle all my needs for random string: initial password for new user, password salt, suffix for an uploaded file, etc.
Key features are:
[list=1]
[*]Definable string length
the function can be called like
echo genRandomString(15)
and it will generate 15-character string. Leave the parameter blank and it will generate 10-character random string
[*]Definable set of characters to be randomized
By default, it uses small and capital letters and numbers to form a random string. You can also use a different set of characters (like Russian or Chinese characters) or use only numbers if you want.
[*]Added: Option not to duplicate characters already used
[/list]
Here is the attachment: 1670
Detailed explanation here: Random String Generator
Just feel like sharing it