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
+7.5k Javascript : Push notifications to browser with Push.js
+21.8k Golang : Use TLS version 1.2 and enforce server security configuration over client
+8.1k Golang : Randomize letters from a string example
+36.2k Golang : Convert(cast) int64 to string
+8.4k Golang : How to check if input string is a word?
+27.4k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+5.9k Golang : Function as an argument type example
+20.6k Golang : Read directory content with os.Open
+15.1k Golang : Accurate and reliable decimal calculations
+15.2k nginx: [emerg] unknown directive "ssl"
+13.8k Golang : Get current time