Handy function for this sort of stuff: http://ircphp.com/users/imho/?file=function.hexview.php
"René fournier" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > When reading from a Socket Server, my Socket Client retrieves data that > includes ASCII and binary data: > > while(($buf = socket_read($socket,128,PHP_BINARY_READ)) !== false) { > $data .= $buf; > if(preg_match("/ENX/", $data)) break; > } > echo "RESPONSE: ".$data."\n"; > > The output looks like: > RESPONSE: STX&The system is up and running.ENX > > Between the "STX" and "The system is up..." are 8 bytes of binary data > (which this case appear as an ampersand), which I want to extract from > $data, split into two 4 byte variables, and convert back into integers. > I suspect that I need unpack() at some point, but any ideas how to > extract and split the binary data from this string? (Sometimes, the > binary data is not visible, but it's still there.) > > ...Rene > > PS. Thanks guys for the earlier advice with pack()--which worked. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php