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
+24k Golang : How to validate URL the right way
+16.2k Golang : Send email and SMTP configuration example
+6.3k Golang : Spell checking with ispell example
+7.8k Golang : Check from web if Go application is running or not
+15k Golang : How to get Unix file descriptor for console and file
+27.7k Golang : Move file to another directory
+12.1k Golang : How to display image file or expose CSS, JS files from localhost?
+7.5k Gogland : Where to put source code files in package directory for rookie
+11.7k Golang : How to parse plain email text and process email header?
+13.8k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+10.8k Golang : Fix go.exe is not compatible with the version of Windows you're running
+40.7k Golang : How to check if a string contains another sub-string?