How to convert an integer to a string in base b with PHP

1 Answer

0 votes
$integer = 255; 
$base = 16;     // base (e.g., 16 for hexadecimal)

$string = strtoupper(base_convert($integer, 10, $base));// Convert from base 10 to base 16
echo $string; 



/*
run:

FF

*/

 



answered Aug 17, 2025 by avibootz
...