I don’t see why not
Hi m@tt,
Well, it looks like the code you gave me, doesn’t work on the other peices of code, as it looks like the strings are in whole numbers. For example, they aren’t 5.0C they are just 5C. So, to make all of the peices of code show 5.0C, I changed:
[php]$mtrInfo[‘TEMP’] = $dewC . “°C”;[/php]
To:
[php]$mtrInfo[‘TEMP’] = $dewC . “.0°C”;[/php]
And:
[php]$mtrInfo[‘DEWPT’] = $dewC . “°C”;[/php]
To:
[php]$mtrInfo[‘DEWPT’] = $dewC . “.0°C”;[/php]
And:
[php]$mtrInfo[‘BAROMETER’] = “$pressureHPA hPa”;[/php]
To:
[php]$mtrInfo[‘BAROMETER’] = “$pressureHPA.0 hPa”;[/php]
Thanks for you help,
William
So if it is 5.1 you want it to display 5.10?
Why wouldn’t you just apply the number_format() function to the variable?
[php]$mtrInfo[‘TEMP’] = $dewC . “°C”;[/php]
To:
[php]$mtrInfo[‘TEMP’] = number_format($dewC, 1) . “°C”;[/php]
Hi m@tt,
Thanks so much! That worked!
I have still 1 problem, though.
How would I change this PHP code, too do what the other peices of code, do?
[php]$mtrInfo[‘BAROMETER’] = “$pressureHPA hPa”;[/php]
Thanks,
William
Hi m@tt,
Ok, I tried changing:
[php]$mtrInfo[‘BAROMETER’] = “$pressureHPA hPa”;[/php]
To:
[php]$mtrInfo[‘BAROMETER’] = number_format($pressureHPA, 1) . “hPa”;[/php]
But, that gave the number format ‘1,010.0 hPa’ not the number format ‘1010.0 hPa’ that I was wanting.
Please can someone help?
Thanks,
William
William, I have to encourage you to check the manual. You can learn a lot
http://www.php.net/number_format
You’ll notice in the manual
number_format ( float $number , int $decimals = 0 , string $dec_point = ‘.’ , string $thousands_sep = ‘,’ )
What this interprets to, if you want to remove the comma, is $thousands_sep = ‘,’ (this is the default value)
So, if you want to remove the comma, you would do
[php]number_format($pressureHPA, 1, ‘.’, ‘’)[/php]
This tells the function to do $decimals = 1, $dec_point = ‘.’, and $thousands_sep = ‘’ (empty string)
Hi m@tt,
Oh, sorry. I forgot to look in the manual! I have seen that page before! LOL
Thanks so much! That worked!
Thanks,
William