H3S1: Decoding binary into int or str:
<php.net>: Returns the decimal equivalent of the binary | number represented by the
binary_string argument. bindec() interprets all
binary_string values as unsigned integers. This is because bindec() sees the most significant bit (??) as another order of magnitude rather than as the sign bit. bindec() converts a binary number to an int or, if needed for size | reasons, float.
bindec(string $binary_string): int|float //example: echo bindec('110011') . " | "; echo bindec('000110011') . " | "; echo bindec('111');
Output: 51 | 51 | 7 Hu: We can deduce from this # that the extraneous zeroes, at the start of a bit | shift, are not accounted for, in returning the final | value. Q: Can these bits be used as empty | space-fillers, when we want to, for example, encode an integer that requires 6 bits, but we need a 1.byte-block?
H5S1: <php.net>: Convert binary data into hexadecimal | representation. Returns an ASCII string containing the hexadecimal | representation of
string. Hexadecimal(adj) = relating to or using a system of numerical notation that has 16 rather than 10 as its base<Ox-lang> Hu: Binary is base-2.
bin2hex(string $string): string
H5S2: <php.net>: Decodes a hexadecimally | encoded binary string.
hex2bin(string $string): string|false
Where string = hexadecimal representation of data. Returns the binary representation of the given data or
false on failure. Hu: Is the binary representation a binary string, of 0s and 1s, or a string of text? Elsewhere, <php.net>: This function does NOT convert a hexadecimal number to a binary number.
$hex = hex2bin("6578616d706c65206865782064617461");
Output: string ‘example hex data’ (length=16) <tested: php.7-4,26 11/2/22, Yakun>
unpack(string $format, string $string, int $offset = 0): array|false
<php.net>: Unpacks from a binary string into an array according to the given
format. The unpacked data is stored in an associative array. To accomplish this you have to name the different format codes and separate them by a slash /. If a repeater argument is present, then each of the array keys will have a sequence number behind the given name. Hu: A list of formats can be found on the doc-page for pack()<a-r>