johnsmith153 Posted November 19, 2008 Share Posted November 19, 2008 Hi, I need to generate a unique 12 digit code. ideally in the format: HBRQLPJKNMYT It MUST be unique - so time() sounds possible. However, time() wouldn't be good as obviously someone could guess this easily. Any ideas? Link to comment https://forums.phpfreaks.com/topic/133321-12-digit-unique-pass-code/ Share on other sites More sharing options...
gevans Posted November 19, 2008 Share Posted November 19, 2008 <?php function uuid(){ $uid = strtoupper(md5(uniqid(rand(), true))); $uuid = substr($uid, 0, 12); return $uuid; } ?> Link to comment https://forums.phpfreaks.com/topic/133321-12-digit-unique-pass-code/#findComment-693369 Share on other sites More sharing options...
johnsmith153 Posted November 19, 2008 Author Share Posted November 19, 2008 Perfect. Link to comment https://forums.phpfreaks.com/topic/133321-12-digit-unique-pass-code/#findComment-693377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.