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
+5.9k Golang : How to call function inside template with template.FuncMap
+6k Golang : How to iterate a slice without using for loop?
+11.1k Golang : convert(cast) string to integer value
+6.2k Golang : Example of custom handler for Gorilla's Path usage.
+5.1k PHP : How to check if an array is empty ?
+5.8k Mac/Linux/Windows : Get CPU information from command line
+31.2k Golang : Regular Expression for alphanumeric and underscore
+6.3k Golang : How to stop user from directly running an executable file?
+6.3k Golang : alternative to os.Exit() function
+11.4k Swift : Convert (cast) Int or int32 value to CGFloat
+9.4k Golang : Underscore string example
+7.7k Golang : Find network service name from given port and protocol