在PHP中将二进制字符串转换为整数

在PHP中将二进制字符串转换为整数

问题描述:

在php中,如何将字符串"1010101010"转换为该二进制数字表示的整数值?

In php how do I convert a string "1010101010" into the integer value represented by this binary number?

例如"10"将变为2,"101"将变为5

eg "10" would go to 2, "101" would go to 5

使用 bindec() 函数从二进制转换为十进制:

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

$value = bindec("10101011010101");