Here is an example of its use. I use it to generate a 40 character session ID for database administrators and users connecting to a remote backend MySQL database through a web interface.
function generateSID() {
//set a random seed using current time
srand(time());
//set up the pool from which the session ID number will be pulled
$var = "ABCDEFGHJKLMNPQRTUVWXY1234567890abcdefghijkmnopqrstuvwxyz1234567890";
//begin the first character of session ID number
$sid .= substr($Pool,(rand()%(strlen($var))),1);
//add the 39 other characters of the session ID number
for($i = 0; $i < 39; $i++) {
$sid .= substr($var,(rand()%(strlen($var))),1);
}
//return the session ID number
return $sid;
}
Hope it shows that rand() does work.
Jim