Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a1e690d1dae2c7493867 to your computer and use it in GitHub Desktop.
Save anonymous/a1e690d1dae2c7493867 to your computer and use it in GitHub Desktop.
generate uuid
<?php
/**
* Plugin Name: Generate a UUID
* Plugin URI: http://xhost.se
* Description: Generates a UUID to use for emediate takeover precision
* Author: Tomas Lindhoff
* Author URI: http://xhost.se
* Version: 0.1
*/
function uuid($prefix = '')
{
$chars = md5(uniqid(mt_rand(), true));
$uuid = substr($chars,0,8) . '-';
$uuid .= substr($chars,8,4) . '-';
$uuid .= substr($chars,12,4) . '-';
$uuid .= substr($chars,16,4) . '-';
$uuid .= substr($chars,20,12);
return $prefix . $uuid;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment