This function will generate a random password string. With the length argument you can controll the number of characters returned.
function generatePassword($length = 8) { return ucfirst(substr(md5(uniqid(rand()),false),0,$length)); }
First letter is always capital, only symbols 0-9 a-f are used...
return substr(base64(mt_rand()),0,$length);
is faster shorter and will do a better job.
You probably meant:
base64_encode(mt_rand()),0,$length);