PHP
0
Вклад в тег
generateUUID = function () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace( /[xy]/g, function ( c ) {
var r = Math.random() * 16 | 0;
return ( c == 'x' ? r : ( r & 0x3 | 0x8 ) ).toString( 16 );
} );
};
protected function generateUId()
{
$idMask = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$result = '';
for ($i = 0; $i < strlen($idMask); $i++) {
if ($idMask[$i] == 'x') {
$result .= $characters[mt_rand(0, 34)];
} else {
$result .= "-";
}
}
return $result;
}