base_convert
string base_convert(string s, int source_base, int destination_base)
s | Original value |
source_base | Original base of number |
destination_base | Base to which to convert |
Converts a number from one base to another.
Returns:
String representation of the converted number; FALSE on error
Description:
base_convert() returns a string representation of the number passed as the first argument. Valid values for source and destination bases can be from 2 to 36. Remember that PHP integers are signed 32-bit numbers, so the maximum value usable here is 2147483647.
Version:
PHP 3 since 3.0.6, PHP 4
See also:
bindec() decbin() dechex() hexdec() decoct() octdec()
Example:
Convert a number’s base
$org = "564"; $new = base_convert($org, 8, 16); ... |
Get PHP Functions Essential Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.