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
+15.1k Golang : Get query string value on a POST request
+8.6k Golang : On lambda, anonymous, inline functions and function literals
+22k Golang : Repeat a character by multiple of x factor
+11k Golang : Calculate Relative Strength Index(RSI) example
+16.2k Golang : Send email and SMTP configuration example
+9k Golang : Gonum standard normal random numbers example
+11.6k Golang : Verify Linux user password again before executing a program example
+42.8k Golang : Convert []byte to image
+10.4k Golang : How to delete element(data) from map ?
+13k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+9.6k Golang : Turn string or text file into slice example