I have created a very basic database which records my appointments against my purchases.
I want to know what my conversion is, to that end i am using the following, however I want it to only display the result to 2 decimal places.
$conversion = $purchases_total / $appts * 100;
$purchases_total is made up of adding 2 variables together, these variables get the info direct from the database. $appts is simply a count of the total entries.
Any assistance in this would be greatly appreciated.
I cant seem to find anything on google or within the forum which fits the bill. I am guessing its something simple but am stuck.
If you need to change the thousands separator or the decimal separator (due to not working in US currency, or a foreign currency that uses a similar definition) then be sure to supply those additional parameters
Number_format returns a string (note: You can see that in the manual page - the return type is listed in the function definition before the function name.), so it’s also perfectly acceptable to call this function amid an echo with appropriate concatenation;
echo “My number is “.number_format($somenumber,2).” so there.”