If you want to convert hex to GUID format (In my case, it was to convert GUID from MSSQL database) :
<?php
function hex2Guid($hex)
{
$hex = [
substr($hex, 0, 8),
substr($hex, 8, 4),
substr($hex, 12, 4),
substr($hex, 16, 4),
substr($hex, 20),
];
$order[0] = [6, 7, 4, 5, 2, 3, 0, 1];
$order[1] = [2, 3, 0, 1];
$order[2] = [2, 3, 0, 1];
$order[3] = [0, 1, 2, 3];
$order[4] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
$result = "";
for($num = 0; $num < count($order); $num++)
{
for($i = 0; $i < count($order[$num]); $i++)
{
$result .= $hex[$num][$order[$num][$i]];
}
if($num != count($order) -1)
{
$result .= "-";
}
}
return strtoupper($result);
}
Example :
echo hex2Guid("64d3938b7008cd4bad5ffe56755d163f");