I did not want to use the one-shot PHP functions like decbin, bindec, dechex, etc... because i wanted to see the individual steps of each operation so i could copy them onto my assignment. So here's the product of about a half hour of fiddling.
It will take an input (number)base and convert it to base10, then convert that base10 number into the final base you asked for.
$base10 = convert_from($number, $from_base);
$to_number = convert_to($base10, $to_base);
print "Input: ($number)$from_base => ($base10)10 => ";
print "Output: ($to_number){$to_base}";
// Output
Converting from input (1101)2 to (x)10
1 * 2^0 = (00000001)10 base10=1
0 * 2^1 = (00000000)10 base10=1
1 * 2^2 = (00000004)10 base10=5
1 * 2^3 = (00000008)10 base10=13
Converting from internal (13)10 to (x)10
13 / 10 = 1 r3
1 / 10 = 0 r1
Input: (1101)2 => (13)10 => Output: (13)10