PHP : Convert(cast) int to double/float
Problem :
You have an integer value and you need to convert it ot double or float value in PHP
Solution :
Use the number_format function to cast the integer to float value. For example :
<?php
$integer = 2;
echo $integer.'<br>';
$float = number_format($integer,3); // up to 3 decimals
echo $float.'<br>';
?>
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
+9k Golang : GMail API create and send draft with simple upload attachment example
+21.8k Golang : Encrypt and decrypt data with TripleDES
+16.5k CodeIgniter/PHP : Create directory if does not exist example
+28.7k Golang : Change a file last modified date and time
+26.2k Mac/Linux and Golang : Fix bind: address already in use error
+8.4k Golang : Check if integer is power of four example
+11.8k Golang : Concurrency and goroutine example
+9.3k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+13.8k Golang : Tutorial on loading GOB and PEM files
+5.7k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+20.6k nginx: [emerg] unknown directive "passenger_enabled"
+9.9k Golang : Qt get screen resolution and display on center example