在PHP中将二进制字符串转换为整数 [英] Convert binary string to integer in 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");
这篇关于在PHP中将二进制字符串转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文