Logo

Programming-Idioms

History of Idiom 176 > diff from v12 to v13

Edit summary for version 13 by user:
New PHP implementation by user [user]

Version 12

2019-04-10, 14:34:20

Version 13

2019-09-26, 16:17:22

Idiom #176 Hex string to byte array

From hex string s of 2n digits, build the equivalent array a of n bytes.
Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).

Idiom #176 Hex string to byte array

From hex string s of 2n digits, build the equivalent array a of n bytes.
Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).

Extra Keywords
hexa
Extra Keywords
hexa
Code
$a = array_map('hexdec', str_split($s, 2));
Comments bubble
PHP does not have a byte type, so an int-array will be returned