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
+2.1k Javascript : Put image into Chrome browser's console
+7.6k Golang : Calculate entire request body length during run time
+1.6k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+4.4k Golang : Gomobile init produce "iphoneos" cannot be located error
+6.3k Golang : Bubble sort example
+6.2k Android Studio : Use image as AlertDialog title with custom layout example
+4.7k Golang : Accept any number of function arguments with three dots(...)
+13.1k Golang : Get ASCII code from a key press(cross-platform) example
+6.7k Golang : How to check if a file is hidden?
+21k Golang : How to count duplicate items in slice/array?
+22.3k Golang : Use wildcard patterns with filepath.Glob() example