Example 1 — Basic bindec() usage
This example converts a few binary strings into decimal numbers.
<?php
echo bindec('1101') . PHP_EOL;
echo bindec('11111111') . PHP_EOL;
echo bindec('110011') . PHP_EOL;
echo bindec('1') . PHP_EOL; How It Works
- 1101 means 8 + 4 + 0 + 1, which is 13.
- Eight 1 digits give 255, the biggest value of one byte.
- 110011 means 32 + 16 + 0 + 0 + 2 + 1, which is 51.
- A single 1 is simply 1.

