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
+19.4k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+27.4k Golang : Find files by name - cross platform example
+30.8k Golang : Remove characters from string example
+12.5k Golang : Simple client-server HMAC authentication without SSL example
+13.3k Golang : Convert(cast) uintptr to string example
+6k Cash Flow : 50 days to pay your credit card debt
+10.3k Golang : Print how to use flag for your application example
+11.4k Golang : Fix - does not implement sort.Interface (missing Len method)
+6.7k Golang : Spell checking with ispell example
+16.5k Golang : How to extract links from web page ?
+10.2k Golang : Setting variable value with ldflags
+11.1k Golang : Get UDP client IP address and differentiate clients by port number