public static function uuid($key = null, $prefix = '')
    {
        $key = ($key == null) ? uniqid(rand()) : $key;
        $chars = md5($key);
        $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;
    }
public static function uuid($key = null, $prefix = '')
    {
        $key = ($key == null) ? uniqid(rand()) : $key;
        $chars = md5($key);
        $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;
    }
public static function uuid ( $ key = null , $ prefix = '' ) { $ key = ( $ key == null ) ? uniqid ( rand ( ) ) : $ key ; $ chars = md5 ( $ key ) ; $ 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 ; }
Generate an UUID.

The UUID is based on an MD5 hash. If no key is given, a unique ID as the input
for the MD5 hash is generated.

@author   Anis uddin Ahmad <admin@ajaxray.com>
@access   public
@param    string $key    optional key on which the UUID is generated
@param    string $prefix an optional prefix
@return   string         the formatted UUID
Generate an UUID .