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
+4.7k Fix fatal error: evacuation not done in time problem
+25k Golang : Calculate future date with time.Add() function
+18.4k Android Studio : AlertDialog and EditText to get user string input example
+14.9k Golang : Test floating point numbers not-a-number and infinite example
+15.1k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+6.1k Golang : Of hash table and hash map
+9k Golang : Text file editor (accept input from screen and save to file)
+11.1k Golang : Listen and Serve on sub domain example
+5.5k Nginx : Password protect a directory/folder
+6.1k Golang : Use modern ciphers only in secure connection
+14.2k Golang : invalid character ',' looking for beginning of value