Example 1 — Powers of Ten
Use log10() to find which power of 10 gives a number.
<?php
echo log10(1000), PHP_EOL;
echo log10(100), PHP_EOL;
echo log10(0.01), PHP_EOL; How It Works
- log10(1000) asks: 10 to which power is 1000? The answer is 3.
- log10(100) returns 2 because 10 squared is 100.
- log10(0.01) returns -2 because 10 to the power -2 is 0.01.
- Results are floats, but whole values print without decimals.

