- Instant help with your Php coding problems

Convert hexadecimal to decimal in PHP

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

$decimal = hexdec($hexadecimal);

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

The hexdec() function returns the decimal equivalent of the hexadecimal number represented by the string type argument. hexdec() converts a hexadecimal string to a decimal number.

hexdec() will ignore any non-hexadecimal characters it encounters. As of PHP 7.4.0 supplying any invalid characters is deprecated.

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