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
+7k Golang : constant 20013 overflows byte error message
+4.1k Javascript : Empty an array example
+8.7k Golang : How to join strings?
+18k Golang : Qt image viewer example
+13.9k Golang : Get current time
+31.7k Golang : Get local IP and MAC address
+15.6k Golang : Force download file example
+5.5k Golang *File points to a file or directory ?
+13.4k Golang : error parsing regexp: invalid or unsupported Perl syntax
+7.8k Golang : Example of how to detect which type of script a word belongs to
+9.9k Golang : Sort and reverse sort a slice of integers
+19.2k Golang : Display list of time zones with GMT