- Instant help with your Php coding problems

Convert hexadecimal to binary in PHP

Question:
How to convert hexadecimal to binary in PHP?
Answer:
$hexadecimal = 'afc758';

$binary = base_convert($hexadecimal, 16, 2);

echo $hexadecimal . ' -> binary value is: ' . $binary;
Description:

The base_convert function converts a number between arbitrary bases. It returns the string representation of the number.

Note: PHP also has a hex2bin function, but it does NOT convert a hexadecimal number to a binary number. 

Share "How to convert hexadecimal to binary in PHP?"
Tags:
convert hex to bin, convert hexadecimal to binary, hexa to binary conversion, hex, bin, hexadecimal, binary, conversion
Technical term:
Convert hexadecimal to binary in PHP