The php Function Base_Convert
The php function base_convert is a useful tool for working with number systems and bases like binary (base 2), decimal (base 10), octal (base 8) and hexadecimal (base 16). It allows you to change the numeric value of a number from its current base to another base, such as changing a decimal number to binary or hexadecimal.
The first argument is the original base of the number, followed by the base to which you want it changed and finally the string representing the converted value. The string is a list of the characters that will be used to represent the digits in the new base. For bases above 10, the letters a through z are used, where a represents 10, b represents 11, and z represents 35. The function is case-insensitive.
It is possible to extend the base_convert function by using other functions such as bindec(), decbin(), dechex(), and octdec() to convert from different number bases. However, this can be confusing, and it would be easier to have a single function that supports all the different bases.
The highest base that base_convert() supports is base 36, which uses 0-9 and then A-Z. If you try to use a larger base, you will receive an error. Alternatively, you can use sprintf( ) to perform similar conversions, but with the advantage that it works with all bases, including binary, octal and hexadecimal. It also supports a wide range of formatting options, such as starting a string with leading 0s or choosing between upper- and lowercase letters for hexadecimal.