C#中有BitConverter.Tostring,可以将byte[] 转换成 21-32-43 这样的结果。 这个byte[] 是从某个字符串中得来。我怎么将字符 21-32-43 转成 那个字符串。比如
byte[] a = System.Text.Encoding.UTF8.GetBytes("winslow");
textBox1.Text = System.BitConverter.ToString(a);这个结果是 77-69-6E-73-6C-6F-77我怎么用php将它转回去。
byte[] a = System.Text.Encoding.UTF8.GetBytes("winslow");
textBox1.Text = System.BitConverter.ToString(a);这个结果是 77-69-6E-73-6C-6F-77我怎么用php将它转回去。
$str = '77-69-6E-73-6C-6F-77';
//1.
echo preg_replace("/(^|\-)[^\-]+/e","chr(hexdec('\\0'))",$str)."<br/>";
//2.
$c = explode('-',$str);
foreach($c as $s)
{
$cs .= chr(hexdec($s));
}
echo $cs;
echo pack('H*', str_replace('-', '', $s));