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.1k Nginx : How to block user agent ?
+17.6k Convert JSON to CSV in Golang
+8.3k Golang : Implementing class(object-oriented programming style)
+8.7k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+21.3k Golang : How to force compile or remove object files first before rebuild?
+6.1k Golang : Scan forex opportunities by Bollinger bands
+13.8k Golang : Convert spaces to tabs and back to spaces example
+4.9k Python : Find out the variable type and determine the type with simple test
+5.2k Golang : Issue HTTP commands to server and port example
+13.2k Golang : How to calculate the distance between two coordinates using Haversine formula
+8.3k Swift : Convert (cast) Character to Integer?
+14.5k How to automatically restart your crashed Golang server