While it's common in other languages (like Java) to get the least significant and most significant bits of a UUID as two unsigned 64-bit integers, PHP has trouble with this because all integers in PHP are signed. Even if using a 64-bit build of PHP, you will run into integer overflows when trying to get a real integer value of the least or most significant bits of a UUID.
The maximum integer value on 64-bit PHP is 9,223,372,036,854,775,807
, while an unsigned 64-bit integer has a max value of 18,446,744,073,709,551,615
. A UUID as two 64-bit integers needs to support values up to 18,446,744,073,709,551,615
.
As an earlier answer mentioned, it might be better to split up the UUID into four unsigned 32-bit integers, if you need to split it up like that. (The max value of an unsigned 32-bit integer is 4,294,967,295
, which 64-bit PHP can support.)
If you're simply interested in storing a UUID in a more optimized way, you can convert it to a 16-byte binary string:
$uuid = '1968ec4a-2a73-11df-9aca-00012e27a270';
$binaryUuid = hex2bin(str_replace('-', '', $uuid));