Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

PHP Number Formats

Status
Not open for further replies.

Admin

Administrator
Staff member
Joined
Jun 14, 2004
Posts
11,137
Reaction score
929
I am trying to format a number being read for a MySQL DB into a PHP page.

My field in the DB is set as decimal (50,0)
My code in my PHP is:
PHP:
<td class="cat">£{$data|number_format}</td>

The output is 4,500.00

How do I change this to drop the decimals i.e. 4,500 ??

Thanks

Admin
 
PHP:
{$data|number_format}

That isn't strictly PHP. It's part of the template parser. However, not sure which one. Could be smarty, which if it is try this:

PHP:
{$data|number_format:0}
 
Yes it's Smarty and it works perfectly.

Thanks a lot, I've been fiddling with that for ages!

Admin
 
No problems. Smarty is v good - we use it for quite a few clients.

Smarty might be worth reading :)
 
Yeah I'm still in the learning curve but results look good.

thanks for the help.

Admin
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
Acorn Domains Merch
MariaBuy Marketplace

New Threads

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom