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
+4.1k Detect if Google Analytics and Developer Media are loaded properly or not
+11.3k Golang : Simple image viewer with Go-GTK
+14k Golang : Get current time
+5.1k Python : Convert(cast) bytes to string example
+5.6k Clean up Visual Studio For Mac installation failed disk full problem
+6.5k Golang : How to search a list of records or data structures
+16.6k Golang : Execute terminal command to remote machine example
+14.1k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+17.6k Golang : Multi threading or run two processes or more example
+26.8k Golang : Encrypt and decrypt data with AES crypto
+14.1k Golang : How to determine if a year is leap year?