In php, the base_convert ()-based numeric conversion function is used. In php, the base_convert ()-based numeric conversion function is used. the base_convert-based example describes how to implement the base_convert () function-based numeric conversion in php. We will share with you the example of the base_convert ()-based digital conversion function in php.
This article describes how to convert the base _ convert () function into numbers in php. Share it with you for your reference. The details are as follows:
Syntax: base_convert (number, frombase, tobase)
| Parameters |
Description |
| Number |
Required, original value. |
| Frombase |
Required. number in the original hexadecimal format. |
| Tobase |
Required. the hexadecimal format to be converted. |
The PHP instance code is as follows:
The code is as follows:
$ Hexadecimal = 'a37334 ';
Echo base_convert ($ hexadecimal, 16,2); // Convert to binary output 101000110111001100110100
Echo"
";
$ Number = "123 ";
Echo base_convert ($ number, 1111011); // Convert to binary output
Echo"
";
Echo base_convert ($ number, 10, 8); // Convert to octal output 173
Echo"
";
Echo base_convert ($ number, 10, 16); // Convert to hexadecimal output 7b
$ Number2 = "100000101 ";
Echo"
";
Echo base_convert ($ number2, 2, 10); // Convert to decimal output 261
Echo"
";
Echo base_convert ($ number2, 2, 8); // Convert to octal output 405
Description: return a string that contains the tobase representation of the number. The number system is specified by frombase. both frombase and tobase can only be between 2 and 36 (including 2 and 36). numbers higher than decimal digits are represented by a-z, for example, a indicates 10, B indicates 11, and z indicates 35.
I hope this article will help you with PHP programming.
An example of the convert () to convert numeric functions. the base_convert in this document describes how to convert the base_convert () function in php. I will share it with you for your reference...