Example 1 — Convert hex strings to decimal
Try uppercase and lowercase hex values.
<?php
echo hexdec("ff") . PHP_EOL;
echo hexdec("1A") . PHP_EOL;
echo hexdec("10") . PHP_EOL; How It Works
- hexdec("ff") is 15 x 16 + 15, which is 255.
- hexdec("1A") is 1 x 16 + 10, which is 26. Letter case does not matter.
- hexdec("10") is 1 x 16 + 0, which is 16.
- Each result is a normal PHP integer you can use in calculations.

