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
+7.2k Golang : alternative to os.Exit() function
+8.8k Golang : HTTP Routing with Goji example
+13.5k Golang : Query string with space symbol %20 in between
+18.4k Golang : Example for RSA package functions
+8.1k Android Studio : Rating bar example
+19.7k Golang : Append content to a file
+7k Nginx : How to block user agent ?
+4.8k Golang : A program that contain another program and executes it during run-time
+23.4k Golang : Read a file into an array or slice example
+17.8k Golang : Simple client server example
+9.3k Golang : Timeout example
+9.3k Golang : Create unique title slugs example