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
+9.3k Golang : Load ASN1 encoded DSA public key PEM file example
+22.3k Golang : simulate tail -f or read last line from log file example
+11.4k Golang : Find and draw contours with OpenCV example
+32.6k Delete a directory in Go
+4.6k Unix/Linux : secure copying between servers with SCP command examples
+10.4k Golang : Removes punctuation or defined delimiter from the user's input
+7.3k Golang : Error reading timestamp with GORM or SQL driver
+11.4k Golang : Verify Linux user password again before executing a program example
+5.4k Cash Flow : 50 days to pay your credit card debt
+12.1k Golang : Arithmetic operation with numerical slices or arrays example
+13k Golang : Read from buffered reader until specific number of bytes
+9.9k Golang : Convert file unix timestamp to UTC time example