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
+7.4k Golang : Rename part of filename
+45.9k Golang : Read tab delimited file with encoding/csv package
+25.5k Golang : Daemonizing a simple web server process example
+5.9k Golang : Function as an argument type example
+22k Golang : Repeat a character by multiple of x factor
+7.5k Golang : Mapping Iban to Dunging alphabets
+7.6k Golang : How to execute code at certain day, hour and minute?
+9.3k Golang : Get all countries currencies code in JSON format
+38.9k Golang : How to iterate over a []string(array)
+11.2k Golang : How to flush a channel before the end of program?
+13.7k Golang : convert(cast) string to float value