PHP : Convert(cast) bigInt to string
Problem :
In PHP, you want to convert(cast) a big integer value to string for display.
Solution :
Use GNU Multiple Precision's gmp_strval() function to convert the big integer value to string.
For example :
<?php
$bigInt = gmp_init("123456789123456789");
$bigIntStr = gmp_strval($bigInt);
echo $bigIntStr."\n";
?>
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) string to bigInt
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.2k Golang : Generate Codabar
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+11.7k Golang : Display a text file line by line with line number example
+10k Golang : Get escape characters \u form from unicode characters
+6.5k Golang : Combine slices of complex numbers and operation example
+51.4k Golang : Check if item is in slice/array
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+5.4k Golang : fmt.Println prints out empty data from struct
+8.3k Prevent Write failed: Broken pipe problem during ssh session with screen command
+14.1k Golang : Compress and decompress file with compress/flate example
+15.1k Golang : package is not in GOROOT during compilation
+15.2k Golang : How to check if IP address is in range