Convert binary string to integer in php

前端 未结 2 826
无人及你
无人及你 2021-01-20 12:07

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

相关标签:
2条回答
  • 2021-01-20 12:20

    Try the bindec() function.

    0 讨论(0)
  • 2021-01-20 12:46

    Use bindec() function to convert from binary to decimal:

    $value = bindec("10101011010101");
    
    0 讨论(0)
提交回复
热议问题