<?php // generate a random, unique ID // result: "5542ec0a1928b99ef90cb87503094fe4" (example) $id = md5(uniqid(rand(), true)); echo $id; ?>
PHP's uniqid( ) function returns an alphanumeric string based on the current time in microseconds and because the identifier is based in a time value, so there is a very slight possibility of two identical identifiers being generated at the same instant. There are to reduce this possibility and add a random element to the procedure by combining the call to uniqid( ) with a call to rand( ) and md5( ).