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
+3.9k Golang : Calculate a pip value and distance to target profit example
+11.8k Golang : Qt progress dialog example
+16.4k Golang : Read data from config file and assign to variables
+15.9k Golang : Get future or past hours, minutes or seconds
+18k Mac OSX : Homebrew and Golang
+11.5k Golang : How to calculate the distance between two coordinates using Haversine formula
+8.3k Golang : Qt Yes No and Quit message box example
+9.1k Golang : Embed secret text string into binary(executable) file
+6.9k Golang : Configure Apache and NGINX to access your Go service example
+39.7k Golang : How to check if a string contains another sub-string?
+16.4k Golang : Aligning strings to right, left and center with fill example
+28k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?