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
+13.9k Golang : syscall.Socket example
+27.3k PHP : Count number of JSON items/objects
+8.2k Golang : Generate Datamatrix barcode
+18.3k Golang : Iterating Elements Over A List
+7.3k Golang : Shuffle strings array
+16.1k Golang : Execute terminal command to remote machine example
+4.7k Golang : Calculate a pip value and distance to target profit example
+8.4k Golang : Progress bar with ∎ character
+16k Golang : How to extract links from web page ?
+5.8k Golang : Grab news article text and use NLP to get each paragraph's sentences
+5.6k Linux : Disable and enable IPv4 forwarding
+5.2k Golang : Get S3 or CloudFront object or file information