Core PHP

Base Conversion Functions

Base Conversion Functions
base_convert()
string base_convert(string $sNumber, integer $iSrcBase, integer $iDestBase)
This function returns a string containing the value of $sNumber in $iSrcBase converted to the number base $iDestBase. The number bases are allowed to be in the range [2, 35] with the case-insensitive letters a-z representing the values 10-35.
Argument Description
string $sNumber This is the number that is to be converted.
int $iSrcBase This is the initial number base.
int $iDestBase This is the target number base.
bin2hex()
string bin2hex(string $sBinary)
This function returns the hexadecimal value, as a string, that corresponds to the numeric value or the string $sBinary in binary digits.
Argument Description
string $sBinary This is a string of 0s and 1s that represents a number in binary.
decbin()
string decbin(double $dDecimal)
This function returns a binary, or base 2, representation of $dDecimal as a string.
Argument Description
double $dDecimal This is the value that is to be converted.
dechex()
string dechex(double $dDecimal)
This function returns a hexadecimal, or base 16, representation of $dDecimal as a string.
Argument Description
double $dDecimal This is the value that is to be converted.
decoct()
string decoct(double $dDecimal)
This function returns a octal, or base 8, representation of $dDecimal as a string.
Argument Description
double $dDecimal This is the value that is to be converted.
hex2bin()
string hex2bin(string $sHexadecimal)
This function returns the binary value, as a string, that corresponds to the numeric value or the string $sHexadecimal in hexadecimal digits. The value FALSE is returned if it fails.
Argument Description
string $sHexadecimal This is a string of 0-F digits that represents a number in hexadecimal.
hexdec()
Integer hexdec(string $sHexadecimal)
This function returns the value of the hexadecimal, base 16, number represented by $sHexadecimal.
Argument Description
string $sHexadecimal This is a hexadecimal representation of a number as a string.
octdec()
Integer octdec(string $sOctal)
This function returns the value of the octal, base 8, number represented by $sOctal.
Argument Description
string $sOctal This is the octal representation of a number as a string.
 
 

© 2007–2024 XoaX.net LLC. All rights reserved.