Backend Development 2 min read

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.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Using PHP's base_convert() to Convert Numbers Between Arbitrary Bases

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:

101000110111001100110100
backend developmentProgrammingNumber Conversionbase_convert
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.