note 15001 added to function.pi.php

From: Date: Thu, 23 Aug 2001 20:45:30 +0000
Subject: note 15001 added to function.pi.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-17041@lists.php.net to get a copy of this message
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 "." */ http://www.php.net/manual/en/function.pi.php

« previous php.notes (#17041) next »