开发者

How do I unpack a binary string in PHP?

开发者 https://www.devze.com 2022-12-28 04:37 出处:网络
How can I do th开发者_C百科is Perl code in PHP? print unpack (\"H*\", pack (\"B*\", \"00000000100000012000000\" ));

How can I do th开发者_C百科is Perl code in PHP?

 print unpack ("H*", pack ("B*", "00000000100000012000000" ));


Since pack/unpack in PHP doesn't support the B type, you'll have to use PHP's other functions instead. In this case, dechex and bindec.

echo dechex( bindec( "00000000100000012000000" ));

Edit: Or do it in a single function with base_convert:

echo base_convert("00000000100000012000000", 2, 16);
0

精彩评论

暂无评论...
验证码 换一张
取 消