I am working on my first real project ever, and I am a bit worried. I am trying to create a unique user id (I am using PHP and mysql). I did some research about this topic, and to be honest with you I was overwhelmed. The last thing I read was about something called uniqid(), but the article says [This function does not guarantee uniqueness of return value. Since most systems adjust system clock by NTP or like, system time is changed constantly... Source PHP manual]. Then I thought about adding a random prefix, and I came with this code below. Is enough for a unique user id ?
<?php
$sub = substr(str_shuffle('AQWZSXEDCRFVTGBYHNUJIKOLMP'),16); // returns the last 10 chars
$shuff = str_shuffle(strval(rand(1000,9999)).$sub); // shuffle the 10 random chars with 4 random number
$user_id = uniqid($shuff);