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
+32.6k Golang : Proper way to set function argument default value
+8.9k Golang : Find and replace data in all files recursively
+6.5k Golang : Convert(cast) io.Reader type to string
+7.6k Golang : Executing and evaluating nested loop in html template
+5.1k PHP : How to check if an array is empty ?
+11k Android Studio : Highlight ImageButton when pressed on example
+13.7k Golang : Get HTTP protocol version example
+15.1k Golang : Test floating point numbers not-a-number and infinite example
+14k Golang : Get timezone offset from date or timestamp
+4.8k Golang : Error handling methods
+5.6k Golang : Spell checking with ispell example
+8.7k Golang : Sort and reverse sort a slice of floats