Re: [PHP2] ECHO Format Ammendment
| From: | Steve Edberg | Date: | Fri, 23 Jun 2000 23:50:20 +0000 |
| Subject: | Re: [PHP2] ECHO Format Ammendment | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2876@lists.php.net to get a copy of this message | ||
At 2:15 PM +0100 6/23/00, Andy Woolley wrote:
Try this instead, echo (number_format($Total, 2)); instead of what I said earlier echo (number_format($Total), 2); Andy.Unfortunately, I don't think PHP2 aka PHP/FI had number_format(); as I recall, that showed up in PHP3.0.something. Can you convince this ISP to upgrade to at least PHP3??? Or, find another ISP that supports PHP3 or 4? PHP/FI is, like, so 1997 ;) However, according to the 2.0 manual at http://www.php.net/manual/phpfi2.html you CAN use sprintf(). - steve
----- Original Message ----- From: "Jo Ann Comito" <jacomito@sprintmail.com> To: "PHP List" <php-general@lists.php.net> Sent: Friday, June 23, 2000 1:49 PM Subject: [PHP-GENERAL] [PHP2] ECHO Format Hi, I'm new to the list and to PHP, but this is an old question. I hope some of you have good memories. The isp which hosts the site I am working on only has PHP ver 2 installed. I have a variable $Total which is the sum of various prices. When I display $Total using ECHO I get a lot of extra zeroes. For example, I get 12345.0000000000 instead of 12345.00. How can I format the ECHO command to give me only 2 decimal places? I posted this question on the phpbuilder forum, but the only response I got was to use printf instead of echo. Unfortunately, PHP 2 does not have a printf function. Anyone remember back to PHP 2 and can answer this? Thanks, Jo Ann+--- "I wear the cheese, it does not wear me..." ------------------------+
| Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu |+----------------------------------- - an unidentified man in a dream ---+