PHP : Convert(cast) bigInt to string
Problem :
In PHP, you want to convert(cast) a big integer value to string for display.
Solution :
Use GNU Multiple Precision's gmp_strval() function to convert the big integer value to string.
For example :
<?php
$bigInt = gmp_init("123456789123456789");
$bigIntStr = gmp_strval($bigInt);
echo $bigIntStr."\n";
?>
Notes :
See http://php.net/manual/en/gmp.installation.php on how to get GMP installed on your server.
Reference :
See also : PHP : Convert(cast) string to bigInt
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+15.1k CodeIgniter/PHP : Create directory if does not exist example
+25.2k PHP : Count number of JSON items/objects
+4.9k Javascript : Get operating system and browser information
+10.6k Golang : List running EC2 instances and descriptions
+12.1k Golang : Fix image: unknown format error
+10.9k Golang : Extract part of string with regular expression
+12k Golang : Compress and decompress file with compress/flate example
+6.3k Golang : Ways to recover memory during run time.
+32.3k Golang : convert(cast) bytes to string
+35k Golang : Convert(cast) int64 to string
+11.5k Golang : Handle or parse date string with Z suffix(RFC3339) example
+26k Golang : Change a file last modified date and time