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
+37.8k Golang : Remove dashes(or any character) from string
+5.3k Golang : Map within a map example
+4.3k Golang : Issue HTTP commands to server and port example
+10.7k Golang : Detect user location with HTML5 geo-location
+11.7k Golang : Convert(cast) uintptr to string example
+5.2k Golang : Experimental emojis or emoticons icons programming language
+9.9k Golang : Read until certain character to break for loop
+6.6k Golang : Generate human readable password
+4.6k PHP : Convert CSV to JSON with YQL example
+8.1k Golang : Detect number of active displays and the display's resolution
+12.9k Golang : syscall.Socket example
+21.5k Golang : Get ASCII code from a key press(cross-platform) example