(PHP 4, PHP 5, PHP 7, PHP 8)
base_convert — 在任意進(jìn)制之間轉換數字
$number
, int $frombase
, int $tobase
): string
返回一字符串,包含 number
以 tobase
進(jìn)制的表示。number
本身的進(jìn)制由
frombase
指定。frombase
和 tobase
都只能在
2 和 36 之間(包括 2 和 36)。高于十進(jìn)制的數字用字母 a-z 表示,例如
a 表示 10,b 表示 11 以及 z 表示 35。
由于使用內部的 "double" 或 "float" 類(lèi)型,base_convert() 的操作可能會(huì )導致大數值中的精度丟失。請參見(jiàn)本手冊的 浮點(diǎn)數 章節以便獲得更多詳細信息。
number
要轉換的數字
frombase
The base number
is in
tobase
The base to convert number
to
number
converted to base tobase
示例 #1 base_convert() 例子
<?php
$hexadecimal = 'A37334';
echo base_convert($hexadecimal, 16, 2);
?>
以上例程會(huì )輸出:
101000110111001100110100