Working with binary data in PHP

codeleakers.com

New Member
I'm writing a client for a binary socket protocol in PHP, and it's a pain. I'm currently using \[code\]pack\[/code\] to convert numbers into binary strings, but it's lacking. Two options \[code\]pack\[/code\] has are:
  • Write a signed 32 bit integer in machine byte order
  • Write an insigned 32 bit integer in big endian byte order
But I need to write signed 32 bit integers in big endian order, as with Java's \[code\]DataOutputStream.writeInteger\[/code\]. \[code\]pack\[/code\] doesn't have that option.Is there a way to do this with \[code\]pack\[/code\], or to transform the output of \[code\]pack\[/code\], or maybe a better library for working with binary data in PHP?
 
Top