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 PHP : See installed compiled-in-modules
+13.1k Golang : Recombine chunked files example
+10.4k Get form post value in Go
+8.2k Golang : How to control fmt or log print format?
+10.5k SSL : The certificate is not trusted because no issuer chain was provided
+9.8k Golang : Sieve of Eratosthenes algorithm
+18.3k Golang : Determine if directory is empty with os.File.Readdir() function
+18.1k Golang : How to run your code only once with sync.Once object
+5k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+6.9k Swift : Convert (cast) String to Double
+13.5k Golang : Find commonalities in two slices or arrays example
+7.9k Golang : Find the length of big.Int variable example