The use of pack and unpack functions in PHP

Source: Internet
Author: User

Http://zengrong.net/post/1715.htm

https://my.oschina.net/goal/blog/195749

    • A:null populated byte string
    • A: space-filled byte string
    • H: Hexadecimal number, low four-byte priority
    • H: Hexadecimal number, high four-byte precedence
    • C: Signed characters
    • C: Unsigned characters
    • S: signed short integer (always 16 bits, machine byte-order)
    • S: unsigned short integer (always 16 bits, machine byte-order)
    • N: unsigned short integer (always 16-bit, large-tailed byte-order)
    • V: unsigned short integer (always 16-bit, small-tailed byte-order)
    • I: Signed integer (machine-related size and byte order)
    • I: unsigned integer (machine-related size and byte order)
    • L: Signed Long Integer (always 32 bits, machine byte-order)
    • L: unsigned long integer (always 32-bit, machine byte-order)
    • N: unsigned long integer (always 32-bit, large-tailed byte-order)
    • V: unsigned long integer (always 32-bit, small-tailed byte-order)
    • F: Floating point number (machine-relative size and representation)
    • D: Double precision Number (machine-related size and representation)
    • x: null bytes
    • X: Backwards One byte
    • @: Fill absolute position with null

First read the file $file = file_get_contents (' filename ');

The unpack (' c* ', $file) function is then used to convert the file (binary data) into an associative array.

The use of pack and unpack functions in PHP

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.