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
+6k Javascript : Generate random key with specific length
+12.9k Golang : How to get a user home directory path?
+16.1k Golang : Execute terminal command to remote machine example
+10.3k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+9.7k Golang : Convert octal value to string to deal with leading zero problem
+29.9k Golang : How to verify uploaded file is image or allowed file types
+42.8k Golang : Get hardware information such as disk, memory and CPU usage
+7.9k Golang : Add build version and other information in executables
+6.1k Golang : Extract sub-strings
+9.6k Golang : Resumable upload to Google Drive(RESTful) example
+6k Apt-get to install and uninstall Golang
+12.8k Golang : Calculate elapsed years or months since a date