In php, you can use the base_convert() function to convert hexadecimal to hexadecimal. This function can convert between any hexadecimal and convert the specified original base to the target base. Only You need to set the original base and the base to be converted; the syntax is "base_convert("value to be converted",16,36)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use base_convert () function to convert hexadecimal to hexadecimal.
base_convert(number,frombase,tobase)
Function converts numbers between arbitrary bases.
Parameter | Description |
---|---|
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 a-z, 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 a-z, such as a for 10, b for 11, and z for 35. |
Example: Convert hexadecimal "2003001" to 36 hexadecimal "JZG8X"
<?php $str="2003001"; $num=base_convert($str,16,36); echo $num; ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert hexadecimal to hexadecimal in php. For more information, please follow other related articles on the PHP Chinese website!