Would some combination of [man]pack/man and [man]bin2hex/man help you?
Or this, perhaps, followed by bin2hex().
function asc2bin ($ascii)
{
while ( strlen($ascii) > 0 )
{
$byte = ""; $i = 0;
$byte = substr($ascii, 0, 1);
while ( $byte != chr($i) ) { $i++; }
$byte = base_convert($i, 10, 2);
$byte = str_repeat("0", (8 - strlen($byte)) ) . $byte; # This is an endian (architexture) specific line, you may need to alter it.
$ascii = substr($ascii, 1);
$binary = "$binary$byte";
}
return $binary;
}
... from the manual notes...