News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Using PHP's NumberFormatter to format currencies
July 29, 2013 @ 10:24:30

Rob Allen has a quick post showing how to use PHP's own NumberFormatter function to correctly format currencies (versus just number_format).

I've been using number_format() for a very long time, but recently discovered that within the intl extension there's a NumberFormatter class available too. This is quite a clever class as it is Locale aware and handles formatting currency, including the correct symbol. You can check if you have the intl extension installed using php -m | grep intl and if you don't then you can install it with apt-get install php5-intl or yum install php-intl assuming you use your distro's stock PHP. (If you compile your own, then --enable-intl is the switch you need.)

He gives some bits of example code showing you how to use this object, formatting the same amount for both the typical UK and German Euro formatting. The formater doesn't do any calculations for you, so the number you give it is what will come out the other side (no current exchange checks). He's also created a helper you can use if you're a Zend Framework v2 user.

0 comments voice your opinion now!
numberformatter numberformat euro german uk

Link: http://akrabat.com/php/using-phps-numberformatter-to-format-currencies

Community News:
Purchase Your PHP Unconference Tickets Now! (Sept. 12th/13th, 2009)
March 12, 2009 @ 07:21:03

The PHP Unconference group (putting on the meetup in Hamburg, Germany in September) has announced that tickets are now officially on sale for the event.

The PHP User Group Hamburg and the Department of Computer Science, University Hamburg, Germany are delighted to invite you to the third PHP Unconference. The main focus of the unconference is PHP and related web technologies. There is no official agenda; anyone can suggest a session. The PHP Unconference 2009 will take place on September 12, 2009 and September 13, 2009 at the Geomatikum, Hamburg University. See the location on Google Maps: http://tinyurl.com/bu5mom.

The tickets cost 25 Euro for both days (Sept 12th & 13th), but students of the Hamburg University can get in for free. You can find out more about the event on the unconference's site and you can reserve your spot now by purchasing your ticket.

0 comments voice your opinion now!
phpunconference unconference ticket buy student euro



Community Events





Don't see your event here?
Let us know!


release deployment conference zendserver series podcast community tips threedevsandamaybe development framework laravel list bugfix interview language code introduction symfony api

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework