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
+13.5k Golang : Submit web forms without browser by http.PostForm example
+7.2k Your page has meta tags in the body instead of the head
+6.4k Golang : Dealing with struct's private part
+3.9k Linux : How to set root password in Linux Mint
+4.5k Golang : If else example and common mistake
+26.1k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+8.3k Golang : Read file with ioutil
+7.2k Golang : HTTP Server Example
+26.6k Get file path of temporary file in Go
+8.3k Golang : How to control fmt or log print format?
+7.4k Golang : Convert word to its plural form example
+12.1k Golang : Linear algebra and matrix calculation example