> 24) . chr(($int >> 16) & 0xff) . chr(($int >> 8) & 0xff) . chr($int & 0xff); } # return a php number from the string you pass in. The first 4 bytes of the # string are read in as a binary value in big-endian format. function from_raw_int($quad) { return (ord(substr($quad, 0, 1)) << 24) + (ord(substr($quad, 1, 1)) << 16) + (ord(substr($quad, 2, 1)) << 8) + ord(substr($quad, 3, 1)); } function int_at($string, $index) { return from_raw_int(substr($string, $index * 4, 4)); } # remove the first 4 bytes of the string, and return them as an int function pop_int(&$string) { $int = from_raw_int(substr($string, 0, 4)); $string = substr($string, 4); return $int; } ?>