My goal is to create a random string, and then create a .html page with that string. It’s going well, except that it’s creating pages at 2^(# of times refreshed). Meaning, i will have one page called et5.html and cf4.html the first time, m52.html, sd0.html, 1m2.html,pl1.html the second, and on and on. How can i fix this?
[php]
<?php
function getUniqueCode($length = "")
{
$code = md5(uniqid(rand(), true));
if ($length != "")
return substr($code, 0, $length);
else
return $code;
}
if ($handle = opendir("."))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file != "index.php" && $file != ".htaccess")
{
$f = getUniqueCode(3);
if ($f != $file)
{
$f .= ".html";
fopen($f, "w");
}
}
}
}
?>
[/php]