1

if i have a number:

$num = 0.00638835;

which is an average of 100 entries. I want to find the average and print it.

$avg = $num/100;

my result prints as:

echo $avg;

6.38835E-5

how can i print it as:

 .000004928 //or whatever the number is
bart2puck
  • 2,432
  • 3
  • 27
  • 53
  • 1
    echo $avg and echo floatval($avg) – bart2puck Dec 21 '17 at 16:52
  • We are always glad to help and support new coders but ***you need to help yourself first. :-)*** After [**doing more research**](https://meta.stackoverflow.com/q/261592/1011527) if you have a problem **post what you've tried** with a **clear explanation of what isn't working** and provide [a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Read [How to Ask](http://stackoverflow.com/help/how-to-ask) a good question. Be sure to [take the tour](http://stackoverflow.com/tour) and read [this](https://meta.stackoverflow.com/q/347937/1011527). – Jay Blanchard Dec 21 '17 at 17:08

3 Answers3

4

https://www.w3schools.com/php/func_string_number_format.asp

$num = 0.00638835;
$avg = $num/100;
echo number_format ($avg, 8);

0.00006388

Sergio Tx
  • 3,706
  • 1
  • 16
  • 29
0

echo number_format($a, 10);
with number format you can select any number of decimals

halojoy
  • 225
  • 2
  • 7
0

$num = 0.00638835;

$avg = $num/100;

echo number_format($avg, 8);

Miguel Torres
  • 27
  • 1
  • 10