generate a random password example

This will generate a random password of a given length, this example is about as easy as it gets for generating passwords

<?php
function generatepassword($len)
{
return substr(md5(rand().rand()), 0, $len);
}
?>

<?php
//this will generate a 9 character password
echo generatepassword(9);
?>