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 : Emulate NumPy way of creating matrix example
+12.8k Golang : zlib compress file example
+9.8k PHP : Get coordinates latitude/longitude from string
+10.2k Golang : Print how to use flag for your application example
+15.3k Golang : How to check if IP address is in range
+17.6k Golang : Find smallest number in array
+8.9k Golang : HTTP Routing with Goji example
+4.4k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+48.3k Golang : How to convert JSON string to map and slice
+5.5k Golang : What is StructTag and how to get StructTag's value?
+5.1k Google : Block or disable caching of your website content