PHP : Convert(cast) string to bigInt
Problem :
In PHP, you want to convert(cast) a string to become big integer value.
Solution :
Use GNU Multiple Precision's gmp_intval() function to convert the string to a big integer value.
For example :
<?php
$str = "123456789123456789";
$bigInt = gmp_init($str);
$bigIntVal = gmp_intval($bigInt);
echo $bigIntVal."\n";
?>
Output :
123456789123456789
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) bigInt to string
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
+14.4k Golang : invalid character ',' looking for beginning of value
+4.3k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+16.2k Golang : Multi threading or run two processes or more example
+2.3k Golang : Switch Redis database redis.NewClient
+12.5k Golang : Query string with space symbol %20 in between
+5.2k PageSpeed : Clear or flush cache on web server
+8.3k Random number generation with crypto/rand in Go
+8.1k Golang : How to check if a string with spaces in between is numeric?
+8.9k Golang : Translate language with language package example
+4.6k Python : Print unicode escape characters and string
+15.1k Golang : Test floating point numbers not-a-number and infinite example