Convert binary string to integer in php
-
09-10-2019 - |
Question
In php how do I convert a string "1010101010" into the integer value represented by this binary number?
eg "10" would go to 2, "101" would go to 5
Solution
Use bindec()
function to convert from binary to decimal:
$value = bindec("10101011010101");
OTHER TIPS
Try the bindec()
function.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow