You are here: Re: Amy's Site question « PHP « IT news, forums, messages
Re: Amy's Site question

Posted by Rene Brehmer on 10/05/89 11:19

Documented research indicate that on Wed, 22 Jun 2005 09:17:48 -0400, Jack
Jackson wrote:

> Hello,
>
> On a site I'm listing measurements in both inches and cm; in the db
> they're stored as inches. To convert them to cm I'm doing:
>
> <?php echo ($cartoon['art_width'] * 2.54); ?> x <?php echo
> ($cartoon['art_height'] * 2.54); ?> cm
>
> How can I limit the result of that math to one decimal place, ie, 9.5
> cm, not 9.523 cm?

number_format() ... it's under Math commands in the manual I believe

so you'd do:

<?php echo(number_format($cartoon['art_width'] * 2.54,1)); ?> x
<?php echo(number_format($cartoon['art_height'] * 2.54,1)); ?> cm

This also puts a , for every thousand by the way. It has an option to feed
it a specific format string, but I never use that part of it, so you'll
have to check the manual for that if you need it, sorry.


Rene
--
Rene Brehmer
aka Metalbunny

We have nothing to fear from free speech and free information on the
Internet, but pop-up advertising!

http://metalbunny.net/
My little mess of things...

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация