gpt4 book ai didi

PHP:如何将 GUID 生成为 char 22?

转载 作者:搜寻专家 更新时间:2023-10-31 20:35:14 25 4
gpt4 key购买 nike

我这样生成我的 GUID:

public static function getGUID(){
if (function_exists('com_create_guid')){
return com_create_guid();
}
else {
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
return $uuid;
}
}

但是对于我正在使用的 API,我需要获取一个 GUID 作为 char 22。我该怎么做?

它应该是这样的:

051MWsLH7jMaiuTyaRbC80

最佳答案

22 个字符的 UUID 称为 XUID。查看说明如何从 UUID here 制作 XUID还有一个到 PHP 库的链接来生成 XUID

关于PHP:如何将 GUID 生成为 char 22?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37320108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com