How to convert a piece of data into hex form

Source: Internet
Author: User
How to convert a piece of data to hex form
It's Jiangzi,

This is a blob of data, I now use stream_get_contents to take him out of the image directly into the right ASCII form, but the agreement is not based on ASCII. How can I take or how to convert a string into a hex form?
------Solution--------------------
Let's get something straight.
The ASCII form on the right side of the figure and the HEX form in the middle are all the same thing (we call it a binary string)
Both representations are not used in the actual data communication, while the communication is still using a binary string

$s = ' abcdefghijklmnop ';
Echo Strtoupper (Join (' ', Str_split (Bin2Hex ($s), 4));
4142 4344 4546 4748 494A 4b4c 4d4e 4f50
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.