Random Variable length String





8
Date Submitted Mon. Oct. 16th, 2006 9:59 AM
Revision 1 of 1
Beginner rdohms
Tags PHP
Comments 2 comments
A very simple yet very useful function to have around. Especially generating session codes, filenames or new passwords

function randomString($length = 32){
        $str = md5(mktime()+rand(0,10000));
        return substr($str,0,$length);
}
 

Rafael Dohms

www.rafaeldohms.com.br
Rafael Dohms
PHP Engineer
http://www.rafaeldohms.com.b

Comments

Comments 32
Sat. Oct. 28th, 2006 3:59 PM    Scripter SCoon
Comments collisions
Thu. Oct. 19th, 2006 7:46 PM    Beginner bugmenot

Voting