Example 1 — Basic base_convert() usage
This example converts numbers between binary, decimal, hexadecimal and base 36.
<?php
echo base_convert('ff', 16, 2) . PHP_EOL;
echo base_convert('255', 10, 16) . PHP_EOL;
echo base_convert('1010', 2, 10) . PHP_EOL;
echo base_convert('zz', 36, 10) . PHP_EOL; How It Works
- 'ff' in base 16 is 255, which is 11111111 in binary.
- Decimal 255 becomes ff in hexadecimal.
- Binary 1010 is 10 in decimal.
- In base 36, z is 35, so 'zz' equals 35 * 36 + 35 = 1295.

