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
+11.1k Golang : Generate DSA private, public key and PEM files example
+5.6k AWS S3 : Prevent Hotlinking policy
+5.9k Golang : Process non-XML/JSON formatted ASCII text file example
+18.8k Golang : Check if directory exist and create if does not exist
+16.1k Golang : How to implement two-factor authentication?
+5.2k Python : Print unicode escape characters and string
+8.8k Golang : Create and shuffle deck of cards example
+11.8k Golang : List running EC2 instances and descriptions
+9.2k Golang : Find correlation coefficient example
+6.5k Swift : substringWithRange() function example
+5.5k Javascript : How to replace HTML inside <div>?
+17.1k Golang : [json: cannot unmarshal object into Go value of type]