How to convert Hex to Byte using PHP -


i having problem convert hex value byte using php. there way this?

this hex value want convert byte : 02 05 12 e6 a3

i have tried pack() function , chr() function didnt helped me on it. can know there way solve this. in advance

choose pack() function task. pack() function packs data binary string. it's syntax pack(format,args+). format required parameter while args optional. specifies format use when packing data. there various formats follows:

a - nul-padded string - space-padded string h - hex string, low nibble first h - hex string, high nibble first c - signed char c - unsigned char s - signed short (always 16 bit, machine byte order) s - unsigned short (always 16 bit, machine byte order) n - unsigned short (always 16 bit, big endian byte order) v - unsigned short (always 16 bit, little endian byte order) - signed integer (machine dependent size , byte order) - unsigned integer (machine dependent size , byte order) l - signed long (always 32 bit, machine byte order) l - unsigned long (always 32 bit, machine byte order) n - unsigned long (always 32 bit, big endian byte order) v - unsigned long (always 32 bit, little endian byte order) f - float (machine dependent size , representation) d - double (machine dependent size , representation) x - nul byte x - 1 byte z - nul-padded string @ - nul-fill absolute position 

note: "z" code added in php 5.5 same functionality "a" perl compatibility


Comments