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
+23.1k Golang : Randomly pick an item from a slice/array example
+12.2k Golang : calculate elapsed run time
+11k Golang : Read until certain character to break for loop
+9.1k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+12.4k Golang : "https://" not allowed in import path
+7k Restart Apache or Nginx web server without password prompt
+13.9k Golang : Get current time
+39k Golang : How to iterate over a []string(array)
+25.8k Golang : How to read integer value from standard input ?
+8.5k Golang : Another camera capture GUI application with GTK and OpenCV
+20.7k Golang : Convert date string to variants of time.Time type examples
+10.1k Golang : Print how to use flag for your application example