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
+8.3k Golang : ffmpeg with os/exec.Command() returns non-zero status
+18.7k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+50.3k Golang : How to get struct field and value by name
+29.8k Golang : Convert an image file to []byte
+7.1k Golang : Variadic function arguments sanity check example
+8.9k Golang : Compare files modify date example
+27.7k Golang : Get first few and last few characters from string
+7.6k Golang : Gaussian blur on image and camera video feed examples
+17.1k Golang : How to get hour, minute, second from time?
+11.4k Golang : zlib compress file example
+24.2k Golang : How to read integer value from standard input ?
+37.6k Golang : How to read CSV file