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
+17.6k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+7.3k Golang : Convert word to its plural form example
+10.6k Golang : Gorilla web tool kit secure cookie example
+8.1k Golang : Generate Codabar
+3.7k Golang : How to pass data between controllers with JSON Web Token
+6.9k Golang : Multiplexer with net/http and map
+4.2k JavaScript/JQuery : Redirect page examples
+16k Golang : Clone with pointer and modify value
+6.2k Golang : Dealing with postal or zip code example
+6.8k Swift : Convert (cast) String to Double
+12.4k Golang : Activate web camera and broadcast out base64 encoded images
+5.2k Golang : Extract sub-strings