/** * Unpack a long. * * @param mixed $value * * @return int the long unpacked */ public static function unpackLong($value) { $first = substr($value, 0, 4); $last = substr($value, 4, 4); // First of all, unpack 8 bytes, divided into hi and low parts $hi = unpack('N', $first); $hi = reset($hi); $low = unpack('N', $last); $low = reset($low); // Unpack 64-bit signed long return Math::unpackI64($hi, $low); }