<?php
function createRandomPassword($long=4) {
$charsL = "abcdefghijklmnopqrstuvwxyz";
$charsU = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$int = "0123456789";
srand((double)microtime()*1000000);
$i = 1;
$pass = '' ;
$randStart = rand(1,3);
while ($i <= $long) {
if ($randStart == 1){
$num = rand() % 26;
$tmp = substr($charsL, $num, 1);
}
if ($randStart == 2){
$num = rand() % 26;
$tmp = substr($charsU, $num, 1);
}
if ($randStart == 3){
$num = rand() % 10;
$tmp = substr($int, $num, 1);
}
$pass = $pass . $tmp;
if ($randStart <= 2 )
$randStart = $randStart +1;
else
$randStart = $randStart -2;
$i++;
}
return $pass;
}
echo createRandomPassword(); //
Sabtu, 24 September 2011
Random PHP Code with Capital, Text and Number
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar