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
+22.8k Golang : Strings to lowercase and uppercase example
+11.6k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+8.4k Golang: Prevent over writing file with md5 hash
+8.2k Golang : Tell color name with OpenCV example
+7k Golang : How to solve "too many .rsrc sections" error?
+17.7k Convert JSON to CSV in Golang
+7.7k Golang : Convert(cast) io.Reader type to string
+13.1k Golang : Get terminal width and height example
+52.7k Golang : How to get struct field and value by name
+14.6k Android Studio : Use image as AlertDialog title with custom layout example
+6.3k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations