Zend - The PHP Company




Passwords

Add Code


uin or pin generator  

Type: code fragment
Added by: buffaloBuff
Entered: 22/01/2002
Last modified: 01/12/2001
Rating: *** (3 votes)
Views: 6501
Function, returning a string of length(n) containing random chracters and numbers (specified in array).


<?
function randomizer($length) {
    
$arr = array("1","2","3","4","5","6","7","8","9","0","q","w","e","r","t",
                    
"y","u","i","o","p","a","s","d","f","g","h","j","k","l",
                    
"z","x","c","v","b","n","m","Q","W","E","R","T","Y","U",
                    
"I","O","P","A","S","D","F","G","H","J","K","L","Z","X",
                    
"C","V","B","N","M");
    
srand((float) microtime() * 1000000);
    for(
$i $length$i 0$i--) {
        
$str .= $arr[rand(0sizeof($arr))];        
    }
    return 
$str;
}
?>


Usage Example


<!-- Simple textfield example -->
<input type="text" name="pin" value="<? echo randomizer(8); ?>">


Rate This Script





Search



This Category All Categories