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
+8.9k Golang : Get final balance from bit coin address example
+12.8k Golang : Pass database connection to function called from another package and HTTP Handler
+9.5k Mac OSX : Get a process/daemon status information
+38k Golang : Converting a negative number to positive number
+10.1k Golang : Channels and buffered channels examples
+17.9k Golang : Iterate linked list example
+7.2k Golang : Get environment variable
+27.5k Golang : Convert CSV data to JSON format and save to file
+14.3k Elastic Search : Mapping date format and sort by date
+5.3k PHP : See installed compiled-in-modules
+18.6k Golang : Aligning strings to right, left and center with fill example
+13.6k Golang : Query string with space symbol %20 in between