Zend - The PHP Company




Passwords

Add Code


Random password  

Type: application
Added by: davve
Entered: 10/02/2003
Last modified: 03/12/2002
Rating: - (fewer than 3 votes)
Views: 3965
A function that randomizes a password string from an array.


<?php
// The function with a default length of 8 characters
function mkpass($length 8)
{
        
// Create a list of characters and digits 
        
$foo array_merge
        
(
                
range("0""9"),
                
range("a""z"),
                
range("A""Z")
        );
        
// A loop to build the randomized string 
        
for ($i;$i<$length;$i++) 
        {
                
$rand_char array_rand($foo);
                
$string .= $foo[$rand_char];
        }
        return(
$string);
}

echo 
"<pre>Password: ".mkpass()."</pre>n";       

?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories