Revisiting the question of converting a binary objectGUID to a string, there's a simpler method that doesn't involve a lot of string manipulation:
function GUIDtoStr($binary_guid) {
$unpacked = unpack('Va/v2b/n2c/Nd', $binary_guid);
return sprintf('%08X-%04X-%04X-%04X-%04X%08X', $unpacked['a'], $unpacked['b1'], $unpacked['b2'], $unpacked['c1'], $unpacked['c2'], $unpacked['d']);
}
You can of course replace "X" with "x" in the sprintf format string if you prefer lower-case hex digits.