■PHP板 質問専用スレッド■

このエントリーをはてなブックマークに追加
659電動ナナシ
>>653
<?
function getRandomString($length) {
$result = "";
# Base Strings
$base = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$baselength = strlen($base) - 1;
for ($i = 0; $i < $length; $i++) {
$pos = rand(0, $baselength);
$result .= substr($base, $pos, 1);
}
return $result;
}

$randomString = getRandomString(5);
echo "\$randstr -> [" . $randomString . "]<br>\r";
?>