Convert a hexadecimal number to octal:
<?php$hex = "E196"; echo base_convert($hex,16,8); ?>The base_convert() function converts numbers between arbitrary bases.
base_convert( number,frombase,tobase );
parameter | describe |
---|---|
number | Required. Specifies the number to be converted. |
frombase | Required. Specifies the original base of the number. Between 2 and 36 (inclusive). Numbers above decimal are represented by the letters az, such as a for 10, b for 11 and z for 35. |
tobase | Required. Specifies the base to be converted. Between 2 and 36 (inclusive). Numbers above decimal are represented by the letters az, such as a for 10, b for 11 and z for 35. |
Return value: | Number is converted to the specified base. |
---|---|
Return type: | String |
PHP version: | 4+ |
Convert octal number to decimal number:
<?php$oct = "0031";echo base_convert($oct,8,10);?>Convert octal number to hexadecimal number:
<?php$oct = "364";echo base_convert($oct,8,16);?>