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
+30.7k Golang : Generate random string
+16.6k Golang : How to implement two-factor authentication?
+10k Golang : Detect number of active displays and the display's resolution
+7.1k Default cipher that OpenSSL used to encrypt a PEM file
+20.4k Golang : Compare floating-point numbers
+18.6k Golang : Example for RSA package functions
+6.8k Golang : Embedded or data bundling example
+10.8k Golang : Allow Cross-Origin Resource Sharing request
+11.3k Google Maps URL parameters configuration
+6.4k Golang : Process non-XML/JSON formatted ASCII text file example
+21.3k Golang : Sort and reverse sort a slice of strings