Monday, March 28, 2011

Generates a random string of variable length


function getUniqueCode($length = "")

  {

   $code = md5(uniqid(rand(), true));

   if ($length != "") return substr($code, 0, $length);

   else return $code;

  }

No comments:

Post a Comment