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
+5.2k Golang : Display advertisement images or strings on random order
+13.2k Generate salted password with OpenSSL example
+5.5k Linux/Unix/PHP : Restart PHP-FPM
+7.3k Golang : Command line ticker to show work in progress
+9.9k Golang : How to check if a website is served via HTTPS
+13k Golang : Date and Time formatting
+7.2k Golang : Rot13 and Rot5 algorithms example
+18.4k Unmarshal/Load CSV record into struct in Go
+3.4k Java : Get FX sentiment from website example
+16.1k Golang : Check if a string contains multiple sub-strings in []string?
+21.5k Golang : Use TLS version 1.2 and enforce server security configuration over client
+54.7k Golang : Unmarshal JSON from http response