Does php have a built in coversion to base32 values?

半世苍凉 提交于 2019-12-24 00:54:10

问题


I know I can use number_format, but is there a way to represent base32 numbers? For example, hex can be represented with 0x... and octal can be represented with a 0 in the front. Is there anything to represent base32 numbers in php?


回答1:


Use the built-in function base_convert. For example:

// To convert from base 10 to base 32:
echo( base_convert( 12345, 10, 32 ) );



回答2:


I never seen a native notation for base32, but there is ofcourse Base_convert() .




回答3:


number_format() cannot be used to 'represent' a base 32 number, I wonder if you mean base_convert (http://php.net/base_convert) to move between bases, e.g.

echo(base_convert('FF', 16, 10));

As for defining them with a special prefix, as far as I'm aware PHP only supports 0 and 0x for octal/hexadecimal.



来源:https://stackoverflow.com/questions/1848601/does-php-have-a-built-in-coversion-to-base32-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!