I have the following hex format in string variable:
$str = "0dae28";
I would like to send the above as hex value (e.g. 0x0dae28) via the socket interface using:
socket_write($spawn,$output,strlen($output));
Therefore, I am curious on what should I do to go from $str to $output so that $output is sent as hex formatted data.
Any input is much appreciated. Thank you!
Use PHP’s
hex2bin()function:Thus, in your case: