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
+6.9k Golang : Decode XML data from RSS feed
+23.6k Golang : Check if element exist in map
+7.5k Linux : How to fix Brother HL-1110 printing blank page problem
+5.4k Golang : How to deal with configuration data?
+5.7k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+7.9k Golang : Getting Echo framework StartAutoTLS to work
+6.9k Golang : Find the longest line of text example
+10.4k Golang : How to check if a website is served via HTTPS
+5.3k Python : Convert(cast) string to bytes example
+5.3k Golang : Experimental Jawi programming language
+5k JQuery : Calling a function inside Jquery(document) block
+21.8k Golang : Setting up/configure AWS credentials with official aws-sdk-go