4

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

wheresrhys
  • 22,558
  • 19
  • 94
  • 162

2 Answers2

9

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

$value = bindec("10101011010101");
Crozin
  • 43,890
  • 13
  • 88
  • 135
2

Try the bindec() function.

István Ujj-Mészáros
  • 3,228
  • 1
  • 27
  • 46