Another Random Generator





1
Date Submitted Tue. Sep. 4th, 2007 7:28 PM
Revision 1 of 1
Helper explode
Tags PHP | Random
Comments 1 comments
This little function does great for passwords, usernames, files, and anything else you need a random string for.

<?php

echo randomkeys(); //random 16 chars

echo randomkeys(7); //random 7 chars

function randomkeys($length=16){
        $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; //You can put any characters you want in here
        for($i=0;$i<$length;$i++)
        {
                $key .= $pattern{rand(0,strlen($pattern))};
        }
        return $key;
}       

?>
 

Comments

Comments strlen()
Wed. Apr. 2nd, 2008 3:10 PM    Scripter sehrgut

Voting

Votes Up


Syntax Master dannyboy
Scripter Pio

Votes Down


Scripter sehrgut