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