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
+6.9k Swift : Convert (cast) String to Float
+29.5k Golang : Get local IP and MAC address
+5k Golang : Extract unicode string from another unicode string example
+5.9k Linux : How to fix Brother HL-1110 printing blank page problem
+11.6k Golang : Qt progress dialog example
+21.2k Golang : Round float to precision example
+7.8k Golang : HTTP Routing with Goji example
+9.3k Golang : How to delete element(data) from map ?
+7.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+14.7k Golang : Delete files by extension
+5.2k Javascript : Generate random key with specific length
+4.9k Golang : Shuffle array of list