Using PHP's base_convert() to Convert Numbers Between Arbitrary Bases
This article explains PHP's base_convert() function, detailing its signature, parameter meanings, supported base range, return value, and provides a concrete example that converts a hexadecimal string to its binary representation.
The PHP function base_convert() converts a number from one base to another, supporting bases between 2 and 36, where digits above 9 are represented by letters a‑z.
Signature: string base_convert(string $number, int $frombase, int $tobase)
Parameters:
$number : the number to be converted.
$frombase : the original base of the number (2‑36).
$tobase : the target base for conversion (2‑36).
Return value: a string containing the representation of $number in the target base.
Example:
Output:
101000110111001100110100Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.