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
+36.5k Golang : Convert date or time stamp from string to time.Time type
+27.8k Golang : dial tcp: too many colons in address
+14.7k Golang : Missing Bazaar command
+10k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+11.7k Golang : Simple file scaning and remove virus example
+12.7k Golang : Exit, terminating or aborting a program
+14.6k Golang : How to pass map to html template and access the map's elements
+11.4k Golang : Fix - does not implement sort.Interface (missing Len method)
+13.7k Golang : Strings comparison
+26.6k Golang : Get executable name behind process ID example