Is there a way to convert a GUID to a UUID in PHP?

I have GUIDs in this format

2k9E4A8DFpFFYsfNkKz5fnx61Ry2xAoO

another example:

MI5kvu_WGg3MLB4l18UG4oJ63a1H8uF_

but I need them in this format:

4a9209bd-9252-4914-01a3-24c283062394

Is there a way to convert them in PHP? How would you convert them back (from UUID to GUID)?


快速肮脏的功能,把你的原始和软化成所需的模式

$guid='2k9E4A8DFpFFYsfNkKz5fnx61Ry2xAoO';

function makeuuid($g){
    $a=array(
        substr($g,0,8),
        substr($g,8,4),
        substr($g,12,4),
        substr($g,16,4),
        substr($g,20,strlen($g))
    );
    return implode('-',$a);
}
echo makeuuid( $guid );

/* outputs: 2k9E4A8D-FpFF-YsfN-kKz5-fnx61Ry2xAoO */
链接地址: http://www.djcxy.com/p/91458.html

上一篇: 调用REST API方法来更新本地管理员密码

下一篇: 有没有办法在PHP中将GUID转换为UUID?