Jump to content

Random AlphaNumeric String


GroundZeroStudios

Recommended Posts

function get_rand_id($length)
{
 if($length>0) 
 { 
 $rand_id="";
  for($i=1; $i<=$length; $i++)
  {
  mt_srand((double)microtime() * 1000000);
  $num = mt_rand(1,36);
  $rand_id .= assign_rand_value($num);
  }
 }
return $rand_id;
}

 

Usage:

 

$id = get_rand_id(24);
// Returns random 24 character string.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.