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
+4.2k Javascript : How to show different content with noscript?
+12k Golang : Perform sanity checks on filename example
+17.6k Golang : Defer function inside init()
+5.2k JavaScript/JQuery : Redirect page examples
+13.4k Golang : Read XML elements data with xml.CharData example
+21.5k Golang : GORM create record or insert new record into database example
+7.3k Golang : Scanf function weird error in Windows
+25.6k Golang : Daemonizing a simple web server process example
+7.2k Golang : Accessing dataframe-go element by row, column and name example
+18.3k Golang : Read binary file into memory
+7.3k Golang : Create zip/ePub file without compression(use Store algorithm)
+7.8k Golang : How to feed or take banana with Gorilla Web Toolkit Session package