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
+12.9k Golang : Read from buffered reader until specific number of bytes
+10k Generate Random number with math/rand in Go
+7.3k Golang : Ways to recover memory during run time.
+7.6k Golang : Multiplexer with net/http and map
+10.2k Golang : Get currencies exchange rates example
+23.5k Golang : Call function from another package
+4.2k Golang : PGX CopyFrom to insert rows into Postgres database
+30.2k Golang : Calculate percentage change of two values
+9k Golang : Scramble and unscramble text message by randomly replacing words
+8.6k Golang : Go as a script or running go with shebang/hashbang style
+16.7k Golang : When to use init() function?