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
+5.5k Golang : Get S3 or CloudFront object or file information
+9.5k Golang : Scramble and unscramble text message by randomly replacing words
+6.1k Golang : Function as an argument type example
+6.7k Golang : Warp text string by number of characters or runes example
+22.8k Golang : Strings to lowercase and uppercase example
+11.1k Nginx : TLS 1.2 support
+5.6k PHP : Fix Call to undefined function curl_init() error
+8.3k Golang : Metaprogramming example of wrapping a function
+10.1k Golang : Get escape characters \u form from unicode characters
+11.4k Golang : Intercept and process UNIX signals example
+15k Golang : How to check for empty array string or string?
+22.9k Golang : untar or extract tar ball archive example