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
+15.5k Golang : Find location by IP address and display with Google Map
+4.5k Java : Generate multiplication table example
+7.6k Golang : Detect sample rate, channels or latency with PortAudio
+11.7k Golang : Calculations using complex numbers example
+6.6k Grep : How to grep for strings inside binary data
+11.8k How to tell if a binary(executable) file or web application is built with Golang?
+5.6k PHP : Convert CSV to JSON with YQL example
+7.7k Gogland : Where to put source code files in package directory for rookie
+7.6k Golang : How to handle file size larger than available memory panic issue
+12.1k Golang : Clean formatting/indenting or pretty print JSON result
+13.1k Golang : List objects in AWS S3 bucket
+23.2k Golang : Randomly pick an item from a slice/array example