Skip to content

Instantly share code, notes, and snippets.

@jasonbronson
Created March 10, 2016 20:30
Show Gist options
  • Save jasonbronson/ca31af6611e07967b050 to your computer and use it in GitHub Desktop.
Save jasonbronson/ca31af6611e07967b050 to your computer and use it in GitHub Desktop.
<?php namespace App\Models;
class GeneralModel{
public function getGUID(){
mt_srand((double)microtime()*15000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$uuid = substr($charid, 0, 8)
.substr($charid, 8, 4)
.substr($charid,12, 4)
.substr($charid,16, 4)
.substr($charid,20,12);
return $uuid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment