note 15001 deleted from function.pi by didou

From: Date: Wed, 23 Jul 2003 01:40:15 +0000
Subject: note 15001 deleted from function.pi by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-52489@lists.php.net to get a copy of this message
Note Submitter: stoneneedle@hushmail.com ---- [Editor's note: for a cleaner and more sane solution to display of floating point numbers, see number_format() and/or round(), apparently the contributor of this note was not aware of those functions] I don't like this pi function. Perhaps in the next version of PHP it could be modified such that you can calculate pi out to a user-defined decimal point. Such as echo pi(2); outputting "3.14" or similar. Here's my code though: /* Calculate pi out to a certain decimal place - limited to how far the original pi() command goes out in the first place */ $pi = substr(pi(), 0,4); echo $pi; /* This example will output "3.14" Note that the substr is at 0,4 because it already counts the "3" and the "." */

« previous php.notes (#52489) next »