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
+8k Golang : How to convert a number to words
+7.8k Golang : Display list of countries and ISO codes
+3.3k PHP : See installed compiled-in-modules
+5.1k Golang : Regular Expression find string example
+7.2k Golang : Convert file unix timestamp to UTC time example
+3.6k Golang : Find the longest line of text example
+13.3k Golang : Read a file into an array or slice example
+6.4k Golang : Get UDP client IP address and differentiate clients by port number
+5.7k Golang : Qt get screen resolution and display on center example
+15.3k Golang : How to make function callback or pass value from function as parameter?
+10.9k Golang : Parsing or breaking down URL