function base_convert() converts any integer value from one base to another : base_convert « Math « PHP






function base_convert() converts any integer value from one base to another

 
<?php 

echo base_convert('123', 10, 10) . "\n"; 
echo base_convert('42', 10, 2) . "\n"; 
echo base_convert('83', 10, 8) . "\n"; 
echo base_convert('291', 10, 16) . "\n"; 


echo base_convert('558147', 10, 32) . "\n"; 
echo base_convert('794523', 10, 36) . "\n"; 


echo base_convert('abcd', 16, 8) . "\n"; 
echo base_convert('abcd', 16, 2) . "\n";
?>
  
  








Related examples in the same category

1.Convert integer values to other bases such as binary or base 32 and base 36
2.string base_convert ( string num, int from_base, int to_base ) convert every base to every other base