TechniqueTo take the natural log of a number, use PHP's log() function: <?php $elog = log (10); ?> CommentsI'm betting that right now you're thinking, "Big deal. I want to find the log of a number with a base of five, not a base of e !" Well, it looks like you forgot your calculus. Remember that
so writing this as an extensible function is <?php function log_n ($number, $base) { return log ($number)/log ($base); } ?> Note For logs of base ten, it is quicker to use the log10() function, like so: $num = log10 ($foonum); |