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.5k Android Studio : Simple input textbox and intercept key example
+18k Golang : How to make function callback or pass value from function as parameter?
+31.2k Golang : Convert []string to []byte examples
+7.4k Golang : Number guessing game with user input verification example
+8.1k Golang : Populate or initialize struct with values example
+15.6k CodeIgniter/PHP : Create directory if does not exist example
+7.3k Golang : Qt splash screen with delay example
+12.1k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+8k Golang : Get final balance from bit coin address example
+9.2k Golang : Channels and buffered channels examples
+4.4k Swift : Convert (cast) Float to Int or Int32 value
+8.2k Golang : Generate EAN barcode